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

PHP Warning when purging all caches: race condition?

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5, 2.6.3, 2.7
    • Fix Version/s: 3.10
    • Component/s: Caching
    • Testing Instructions:
      Hide
      1. Check in /cache/admin.php that your Moodle system has the 'core coursemodinfo' cache configured to use a file store (not Redis or anything else). This is default, but it's possible you might have changed it.
      2. Also check in admin settings / Development / Debugging that debugging is set to 'Developer' level and is set to display in the output.
      3. Copy the attached purge-conflict.php file into the root directory of your Moodle testing system.
      4. Open 2 different web browsers. Either use 2 different browsers e.g. Firefox, Chrome or else use one 'normal' browser and one copy in private/incognito mode - the point is that you will need two different Moodle sessions at once.
      5. In the first browser (Browser A), go to a Moodle page and log in. Get ready to do 'purge all caches' quickly - either from the link at the bottom of the page (if enabled) or from the page in site admin under Development.
      6. In the second browser (Browser B), go to /purge-conflict.php - the page should load, displaying a link to 'Go!'
      7. Click the link to 'Go!' in browser B. Wait until it starts displaying dots.
      8. Quickly purge all caches in browser A. You need to have started, and ideally finished, the purge caches process before browser B finishes displaying dots.
      9. Check the purge caches (Browser A) complete without errors (so no 'Directory not empty' errors are displayed).
        • Note: You may still see an error 'failed to open stream: No such file or directory' in browser B. This is probably OK, I got the same error before and after this change.
      Show
      Check in /cache/admin.php that your Moodle system has the 'core coursemodinfo' cache configured to use a file store (not Redis or anything else). This is default, but it's possible you might have changed it. Also check in admin settings / Development / Debugging that debugging is set to 'Developer' level and is set to display in the output. Copy the attached purge-conflict.php file into the root directory of your Moodle testing system. Open 2 different web browsers. Either use 2 different browsers e.g. Firefox, Chrome or else use one 'normal' browser and one copy in private/incognito mode - the point is that you will need two different Moodle sessions at once. In the first browser (Browser A), go to a Moodle page and log in. Get ready to do 'purge all caches' quickly - either from the link at the bottom of the page (if enabled) or from the page in site admin under Development. In the second browser (Browser B), go to /purge-conflict.php - the page should load, displaying a link to 'Go!' Click the link to 'Go!' in browser B. Wait until it starts displaying dots. Quickly purge all caches in browser A. You need to have started, and ideally finished, the purge caches process before browser B finishes displaying dots. Check the purge caches (Browser A) complete without errors (so no 'Directory not empty' errors are displayed). Note: You may still see an error 'failed to open stream: No such file or directory' in browser B. This is probably OK, I got the same error before and after this change.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull 3.10 Branch:
      MDL-38350-m310
    • Pull Master Branch:
      MDL-38350-master

      Description

      Never hit before now, I was using 3 tabs each with a Moodle page using them quite at the same time and one of them used to trigger the Purge all caches (http://localhost/moodle-master/admin/purgecaches.php) action.

      PHP Warning:  rmdir(/path/to/moodle-master-data/cache/cachestore_file/default_application) [<a href='function.rmdir'>function.rmdir</a>]: Directory not empty in /path/to/moodle-master/lib/moodlelib.php on line 10750
      

        Attachments

        1. purge_all_caches.png
          purge_all_caches.png
          147 kB
        2. purge-conflict.php
          2 kB
        3. purge-conflict.png
          purge-conflict.png
          120 kB
        4. test.php
          0.8 kB

          Issue Links

            Activity

              People

              Assignee:
              quen Sam Marshall
              Reporter:
              matteo Matteo Scaramuccia
              Peer reviewer:
              Tim Hunt
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              sumit negi
              Participants:
              Component watchers:
              Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              8 Vote for this issue
              Watchers:
              24 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/20

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 6 hours
                  6h