Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-5411

Increasing the odds of long-running procedures completing successfully

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.2
    • Fix Version/s: 4.3.0
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      On a tunned server, the MySQL Global variable for wait_timeout will likely be tunned rather low. These variables tell MySQL to terminate any open connections that haven't done anything in a while. Since there may be as many as 4 connections open to the database at one time (The Drupal database and the CiviCRM database by both Drupal and CiviCRM) this causes a problem during long running operations. CiviCRM may for example be synchronizing users to contacts for several minutes, finish, and then return control to the CRM. The CRM tries to run a query, only to discover that "The MySQL database has gone away".

      Luckily enough you can override this global variable for the current session. I propose something like the following that could be called for things like import, syncing users to contacts, or anything else that is expected to take a long time:

      function increaseWaitTimeout() {
      // Increase the timeout on the CiviCRM core DB
      civicrm_initialize();
      require_once('CRM/Core/DAO.php');
      CRM_Core_DAO::executeQuery('SET SESSION wait_timeout = 900', CRM_Core_DAO::$_nullArray);

      // Do the same for the CRM Host DB.
      // Not sure how CiviCRM switches between DBs.

      // Do the same for the Host's DBs. Drupal version below.
      }

      function increaseWaitTimeoutDrupal() {
      global db_url;
      if (is_array($db_url)) {
      foreach ($db_url as $db_key => $db)

      { db_set_active($db_key); db_query('SET SESSION wait_timeout = 900'); }

      db_set_active();
      }
      else

      { db_query('SET SESSION wait_timeout = 900'); }

      }

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              dalin dave hansen-lange
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: