Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-49489

coursecontacts regularly (unnecessarily?) purging

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.7, 2.8.5
    • Fix Version/s: 2.7.8, 2.8.6, 2.9
    • Component/s: Caching
    • Labels:
    • Testing Instructions:
      Hide
      1. Edit lib/coursecatlib.php, change CACHE_COURSE_CONTACTS_TTL to 1 second (so you don't have to keep waiting around)
      2. Create a new course
      3. On course/search.php search for that course so it shows up, should have no teachers listed
      4. Add a teacher
      5. Search again, the new teacher should be shown
      6. Add another teacher
      7. Search again, the new teacher should be shown
      8. Remove a teacher
      9. Search again, that teacher should disappear
      10. Remove the last teacher
      11. Search again, that teacher should disappear
      Show
      Edit lib/coursecatlib.php , change CACHE_COURSE_CONTACTS_TTL to 1 second (so you don't have to keep waiting around) Create a new course On course/search.php search for that course so it shows up, should have no teachers listed Add a teacher Search again, the new teacher should be shown Add another teacher Search again, the new teacher should be shown Remove a teacher Search again, that teacher should disappear Remove the last teacher Search again, that teacher should disappear
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      patch-1

      Description

      We're still working out how best to configure all of the various cache definitions, and I've been looking at how frequently the various cache definitions are purged in a production environment.
      When a cache definition is on a memcached server shared with other definitions, purging one definition will purge the others as well, as Memcached can't segregate the various definitions.

      It seems the coursecontacts cache regularly purges itself, even though it seems to have fairly simple keys.

      The code (/lib/coursecatlib.php @ ~713-718 in 2.8.5) looks like this:

      $cacheddata = $cache->get_many(array_merge(array('basic'), array_keys($courses)));
      if (...) {
          $cache->purge();
          $cache->set('basic', ...
      }
      

      It seems the keys are all course ids (and 'basic') - so purging a list of course IDs would seem to make more sense, to prevent the purge?

      $cacheddata = $cache->get_many(array_merge(array('basic'), array_keys($courses)));
      if (...) {
          $cache->delete_many($DB->get_fieldset_select('course', 'id', ''));
          $cache->set('basic', ...
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/May/15