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

Smart group cache-build fails for extremely large groups

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.2.1
    • Component/s: None
    • Labels:
      None

      Description

      The smart group cache-build mechanism (CRM_Contact_BAO_GroupContactCache::load) produces an out-of-memory error when processing large smart-groups. Specifically, it includes this:

      --------
      $dao = CRM_Core_DAO::executeQuery( $sql );

      $values = array( );
      while ( $dao->fetch( ) ) {
      $values[] = "({$groupID},{$dao->$idName})";
      }

      $groupIDs = array( $groupID );
      self::remove( $groupIDs );
      self::store ( $groupIDs, $values );
      --------

      The snippet loads the full group membership into memory before writing it out – which leads to the out-of-memory exception. Recommended steps:

      • Write some unit-tests for smart groups
      • Update GroupContactCache to use "INSERT INTO ... SELECT ..."

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              timotten Tim Otten
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: