Body: <p>We have an email newsletter with about 40,000 subscribers. It is organised simply by a group. So everybody, who is member of this group gets the mailing (unless email is not on hold etc etc).</p>
  
  <p>For the second time we have the issue, that nearly every recipient got the mailing twice. In one case 57 recipients got only one mail, in the other case 39. All the others got the same email two times.</p>
  
  <p>People get upset by this, so I am quite interested in solving this issue.</p>
  
  <p>What I can see, is that there are in both cases two jobs for the mailing, that are no tests. One is obiously a parent job and the other a child job. And all the mailing_event_queue entries belong to the child job.</p>
  
  <p>All of this seems to be quite normal, because the other mailings look the same. The only strange thing is, that in these two cases the child job has nearly twice as much mailing_event_queue entries than recipients.</p>
  
  <p>I only have access to log data of the second mailing, that has doubled sent mails. And in this case I found the anomaly, that the scheduled job, that sent this mailing reported "DB Error: constraint violation". And looking closer into this, it seems, that in between the time of selecting the recipients and sending the mail one recipient was deleted by an API call. Because of this the insert into the table mailing_event_queue failed because the foreign key for the email id, that was not longer found in the database.</p>
  
  <p>Does any body have an idea, if there can be a connection between this error and sending the mailing to most of the recipients two times?</p>
  
  <p>What should happen, if a email (or a contact and its email) get physically deleted between selection of recipients and sending of emails?</p>
  
  <p>Is there an API version of deleting a contact, that takes care of this?</p>
  
  <p>Or is it the process of sending the emails, that should take care of this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-31T06:51:12.710Z
Comments.Text: what's civicrm version ?
Comments.UserDisplayName: Sunil Pawar
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-31T08:40:41.493Z
Comments.Text: CiviCRM 7.x-5.17.4 / FlexMailer 1.1.0 with Drupal 7.67
Comments.UserDisplayName: Harald Balluch
Tags: <civimail>
Title: Mailings get sent twice
ThreadText: # Mailings get sent twice
  
  (Asked by: username_0 on 2019-10-30)
  
  We have an email newsletter with about 40,000 subscribers. It is organised simply by a group. So everybody, who is member of this group gets the mailing (unless email is not on hold etc etc).
  
  For the second time we have the issue, that nearly every recipient got the mailing twice. In one case 57 recipients got only one mail, in the other case 39. All the others got the same email two times.
  
  People get upset by this, so I am quite interested in solving this issue.
  
  What I can see, is that there are in both cases two jobs for the mailing, that are no tests. One is obiously a parent job and the other a child job. And all the mailing\_event\_queue entries belong to the child job.
  
  All of this seems to be quite normal, because the other mailings look the same. The only strange thing is, that in these two cases the child job has nearly twice as much mailing\_event\_queue entries than recipients.
  
  I only have access to log data of the second mailing, that has doubled sent mails. And in this case I found the anomaly, that the scheduled job, that sent this mailing reported "DB Error: constraint violation". And looking closer into this, it seems, that in between the time of selecting the recipients and sending the mail one recipient was deleted by an API call. Because of this the insert into the table mailing\_event\_queue failed because the foreign key for the email id, that was not longer found in the database.
  
  Does any body have an idea, if there can be a connection between this error and sending the mailing to most of the recipients two times?
  
  What should happen, if a email (or a contact and its email) get physically deleted between selection of recipients and sending of emails?
  
  Is there an API version of deleting a contact, that takes care of this?
  
  Or is it the process of sending the emails, that should take care of this?
  
  **Tags:** civimail
  
  > **Comments:**
  > **username_1**: what's civicrm version ?  
  > **username_0**: CiviCRM 7.x-5.17.4 / FlexMailer 1.1.0 with Drupal 7.67  
  
  ---
  
  ## 0 answers
  
  