Answers.Body: <p>This sounds like corrupt tables or a stuck MySQL process.</p>
  
  <p>If you have access to phpMyAdmin, you can select all tables at the bottom and then choose "repair tables".</p>
  
  <p>If you do not have phpMyAdmin, but you have access to ssh then you can use mysqlrepair (or mysqlcheck -r), see more at <a href="http://linuxcommand.org/man_pages/mysqlcheck1.html" rel="nofollow">http://linuxcommand.org/man_pages/mysqlcheck1.html</a></p>
  
  <p>If you have neither you should ask your hoster to do a repair for all tables.</p>
  
  <p>Besides that, restarting MySQL makes sense.</p>
  
  <p>If you need further MySQL tweaking, please look at <a href="http://mysqltuner.com/" rel="nofollow">http://mysqltuner.com/</a>
  Nothing I have seen beats that script.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T07:55:56.030Z
Answers.Text: Thanks a load! Besides that, do you know if changing the group type to include mailinglist should always take so long? What's happening behind the scenes?
Answers.UserDisplayName: nielo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T08:38:48.000Z
Answers.Text: no, should be a breaze, as far as I know it's only one field updated.
Answers.UserDisplayName: Catorghans
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T08:41:36.210Z
Answers.Text: Hmm, lasts minutes for small groups. Do you think it would be fine to update this field in the db for sepecified groups?
Answers.UserDisplayName: nielo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T08:46:48.693Z
Answers.Text: Did repair tables and restart have an effect? If not then I guess we should have a look at mysql config. 180K Contacts and 2K Groups get to the scale that default config might not be optimal.
Answers.UserDisplayName: Catorghans
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T13:04:58.847Z
Answers.Text: Yeah, effect was:  no errors anymore.
  But changing to mailinglist keeps working incredibly slow. 
  I did some optimizations in mysql server config but I'd appreciate some tips.
Answers.UserDisplayName: nielo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T13:54:54.703Z
Answers.Text: See update :) http://mysqltuner.com/ has quite often been a life saver for me.
Answers.UserDisplayName: Catorghans
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-18T21:45:25.447Z
Answers.LastActivityDate: 2016-01-19T13:54:15.033Z
Answers.LastEditDate: 2016-01-19T13:54:15.033Z
Answers.UserDisplayName: Catorghans
Body: <p>Hejdo,</p>
  
  <p>Today I just wanted to make some of our groups accessible by CiviMail by checking the mailinglist group type checkbox. But this took long time (more than 10 minutes) no matter if I did this for a group with about 10 or about 2k contacts. I also tried via group api, same same. </p>
  
  <p>The ui ajax call responds with error and the corresponding log entry states:</p>
  
  <pre><code>"DB Error: unknown error", -1, 16, (Array:2), "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) VALUES (...")
  [...]
  Deadlock found when trying to get lock; try restarting transaction
  </code></pre>
  
  <p>We have somewhere around 180k contacts and 2k groups. Civi is 4.6.10. CMS is current Drupal 7, DB is Mysql 5.5.46. </p>
  
  <p>Any ideas on how to solve it or investigate on?</p>
  
Tags: <groups><error><mailing>
Title: Changing group_type to mailinglist fails with unknown db error / deadlock
ThreadText: # Changing group_type to mailinglist fails with unknown db error / deadlock
  
  (Asked by: username_0 on 2016-01-18)
  
  Hejdo,
  
  Today I just wanted to make some of our groups accessible by CiviMail by checking the mailinglist group type checkbox. But this took long time (more than 10 minutes) no matter if I did this for a group with about 10 or about 2k contacts. I also tried via group api, same same.
  
  The ui ajax call responds with error and the corresponding log entry states:
  
  ```
  "DB Error: unknown error", -1, 16, (Array:2), "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) VALUES (...")
  [...]
  Deadlock found when trying to get lock; try restarting transaction
  
  ```
  
  We have somewhere around 180k contacts and 2k groups. Civi is 4.6.10. CMS is current Drupal 7, DB is Mysql 5.5.46.
  
  Any ideas on how to solve it or investigate on?
  
  **Tags:** groups, error, mailing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-18. Score: 2 | Accepted answer
  
  This sounds like corrupt tables or a stuck MySQL process.
  
  If you have access to phpMyAdmin, you can select all tables at the bottom and then choose "repair tables".
  
  If you do not have phpMyAdmin, but you have access to ssh then you can use mysqlrepair (or mysqlcheck -r), see more at <http://linuxcommand.org/man_pages/mysqlcheck1.html>
  
  If you have neither you should ask your hoster to do a repair for all tables.
  
  Besides that, restarting MySQL makes sense.
  
  If you need further MySQL tweaking, please look at <http://mysqltuner.com/>
  Nothing I have seen beats that script.
  
  > **Comments:**
  > **username_0**: Thanks a load! Besides that, do you know if changing the group type to include mailinglist should always take so long? What's happening behind the scenes?  
  > **username_1**: no, should be a breaze, as far as I know it's only one field updated.  
  > **username_0**: Hmm, lasts minutes for small groups. Do you think it would be fine to update this field in the db for sepecified groups?  
  > **username_1**: Did repair tables and restart have an effect? If not then I guess we should have a look at mysql config. 180K Contacts and 2K Groups get to the scale that default config might not be optimal.  
  > **username_0**: Yeah, effect was:  no errors anymore. But changing to mailinglist keeps working incredibly slow.  I did some optimizations in mysql server config but I'd appreciate some tips.  
  > **username_1**: See update :) http://mysqltuner.com/ has quite often been a life saver for me.  
  
  ---
  
  