Answers.Body: <p>From <a href="https://issues.civicrm.org/jira/browse/CRM-9153" rel="nofollow noreferrer">https://issues.civicrm.org/jira/browse/CRM-9153</a></p>
  
  <p>For multi-sites with a large number of sites (e.g. NYSS with 80 sites), running on a few servers we might want the number of cronjobs processing a mailing to be limited across ALL sites, not across one specific site. Fortunately MySQL locking mechanism is server-wide and we can reuse this, which also means this will not work on sites with multiple MySQL servers. Briefly, we will:</p>
  
  <ol>
  <li><p>Introduce a global setting that allows the admin to enable server wide locks (false by default)</p></li>
  <li><p>Modify the core locking code, CRM_Core_Lock to enable calling functions to specific if server wide locks or site specific locks should be used. Site specific locks are the default</p></li>
  <li><p>Modify the cron script to read this setting and choose the locking mechanism</p></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-19T19:43:38.277Z
Answers.LastActivityDate: 2017-02-19T19:43:38.277Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>From the comments in CRM/Core/Lock.php:</p>
  
  <pre><code>   * @param bool $serverWideLock                                                                                                    
     *   Should this lock be applicable across your entire mysql server.                                                              
     *   this is useful if you have multiple sites running on the same                                   
     *   mysql server and you want to limit the number of parallel cron                                  
     *   jobs - CRM-91XX                                                                                 
  </code></pre>
  
  <p>So basically if you are running multiple civicrm instances on one box and want to limit the number of mailing jobs happening across all instances. This was funded by NYSS and was applicable to their installation.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-15T19:40:58.303Z
Answers.Text: So the lock is put on the ability of an instance to run its mailing queue?
Answers.UserDisplayName: Joe Murray
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-15T18:44:42.870Z
Answers.LastActivityDate: 2015-05-15T18:44:42.870Z
Answers.UserDisplayName: Donald Lobo
Body: <p>At Administer > CiviMail > CiviMail Component Settings, there is a setting called 'Enable global server wide lock for CiviMail'. What does it do? When it is a good idea for a site to have it and when it is a good idea for a site to have it on?</p>
  
Tags: <civimail><settings>
Title: What does 'Enable global server wide lock for CiviMail' do?
ThreadText: # What does 'Enable global server wide lock for CiviMail' do?
  
  (Asked by: username_0 on 2015-05-15)
  
  At Administer > CiviMail > CiviMail Component Settings, there is a setting called 'Enable global server wide lock for CiviMail'. What does it do? When it is a good idea for a site to have it and when it is a good idea for a site to have it on?
  
  **Tags:** civimail, settings
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-05-15. Score: 4 | Accepted answer
  
  From the comments in CRM/Core/Lock.php:
  
  ```
     * @param bool $serverWideLock                                                                                                    
     *   Should this lock be applicable across your entire mysql server.                                                              
     *   this is useful if you have multiple sites running on the same                                   
     *   mysql server and you want to limit the number of parallel cron                                  
     *   jobs - CRM-91XX                                                                                 
  
  ```
  
  So basically if you are running multiple civicrm instances on one box and want to limit the number of mailing jobs happening across all instances. This was funded by NYSS and was applicable to their installation.
  
  > **Comments:**
  > **username_0**: So the lock is put on the ability of an instance to run its mailing queue?  
  
  ---
  
  ### Answer by username_1 on 2017-02-19. Score: 2
  
  From <https://issues.civicrm.org/jira/browse/CRM-9153>
  
  For multi-sites with a large number of sites (e.g. NYSS with 80 sites), running on a few servers we might want the number of cronjobs processing a mailing to be limited across ALL sites, not across one specific site. Fortunately MySQL locking mechanism is server-wide and we can reuse this, which also means this will not work on sites with multiple MySQL servers. Briefly, we will:
  
  1. Introduce a global setting that allows the admin to enable server wide locks (false by default)
  2. Modify the core locking code, CRM\_Core\_Lock to enable calling functions to specific if server wide locks or site specific locks should be used. Site specific locks are the default
  3. Modify the cron script to read this setting and choose the locking mechanism
  
  
  ---
  
  