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

Unnecessary updates of lastinvalidation cache entries

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8.8, 2.9.2, 3.0
    • Fix Version/s: 2.9.4
    • Component/s: Caching
    • Labels:
    • Testing Instructions:
      Hide

      Ensure unit tests pass.

      Verify that application cache invalidation still works:

      1. Go to site "Administration->Courses->Manage courses and categories".
      2. Create a subcategory named "Subcategory" of the Miscellaneous category.
      3. Click on "Subcategory"
      4. Click on "Create a new course" in "Subcategory"
      5. Enter name/shortname as anything. Click on "Save and display"
      6. Verify that the breadcrumbs show that the course is in Miscellaneous / Subcategory
      7. In a new tab, go back to "Administration->Courses->Manage courses and categories"
      8. Edit the subcategory settings, and change the parent to "Top"
      9. In the first tab, reload the course page. Verify that the breadcrumbs now show Subcategory as a top-level category.

      Verify that session invalidation still works:

      1. Open two separate browsers (or one tab in ingognito mode in chrome.)
      2. In browser 1, login as guest and view the courses index. Verify that you can see the Miscellaneous category.
      3. In browser 2, login as admin and go to "Site Adminitstration -> Courses -> Manage courses and categories" and Hide the miscellaneous category.
      4. In browser 1, reload the page. Verify that Miscellaneous disappears.
      5. In browser 2, Un-hide the miscellaneous category.
      6. In browser 1, reload the page. Verify that Miscellaneous reappears.
      Show
      Ensure unit tests pass. Verify that application cache invalidation still works: Go to site "Administration->Courses->Manage courses and categories". Create a subcategory named "Subcategory" of the Miscellaneous category. Click on "Subcategory" Click on "Create a new course" in "Subcategory" Enter name/shortname as anything. Click on "Save and display" Verify that the breadcrumbs show that the course is in Miscellaneous / Subcategory In a new tab, go back to "Administration->Courses->Manage courses and categories" Edit the subcategory settings, and change the parent to "Top" In the first tab, reload the course page. Verify that the breadcrumbs now show Subcategory as a top-level category. Verify that session invalidation still works: Open two separate browsers (or one tab in ingognito mode in chrome.) In browser 1, login as guest and view the courses index. Verify that you can see the Miscellaneous category. In browser 2, login as admin and go to "Site Adminitstration -> Courses -> Manage courses and categories" and Hide the miscellaneous category. In browser 1, reload the page. Verify that Miscellaneous disappears. In browser 2, Un-hide the miscellaneous category. In browser 1, reload the page. Verify that Miscellaneous reappears.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-51482-lastinvalidation-handling

      Description

      Caches which rely on invalidation events (e.g. coursecattree) keep a special cache entry with a timestamp of the last invalidation time. As implemented now, this timestamp updates on every cache access. In the case of coursecattree, this is nearly every page load.

      In theory this is only a minor performance hit. However, when caching via a mechanism that doesn't support absolutely reliable locking (e.g. clustered NFS) this continual rewriting greatly increases the risk of a read of partially written data. On our clustered sites we were we seeing dozens of "unserialization errors" a day because of this problem.

      The fix is simple: Only update the lastinvalidation timestamp when an actual invalidation event is processed.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jan/16