Moodle
  1. Moodle
  2. MDL-38350

PHP Warning when purging all caches: race condition?

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.5
    • Fix Version/s: STABLE backlog
    • Component/s: Caching
    • Labels:
    • Affected Branches:
      MOODLE_25_STABLE
    • Rank:
      48236

      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
      

        Issue Links

          Activity

          Hide
          Matteo Scaramuccia added a comment -

          Now that we have MUC what about reducing the scope of the remove_dir call in purge_all_caches?

          diff --git a/lib/moodlelib.php b/lib/moodlelib.php
          index 5e89439..8e0a07b 100644
          --- a/lib/moodlelib.php
          +++ b/lib/moodlelib.php
          @@ -1557,7 +1557,7 @@ function purge_all_caches() {
               cache_helper::purge_all();
          
               // purge all other caches: rss, simplepie, etc.
          -    remove_dir($CFG->cachedir.'', true);
          +    remove_dir($CFG->cachedir.'');
          
               // make sure cache dir is writable, throws exception if not
               make_cache_directory('');
          
          Show
          Matteo Scaramuccia added a comment - Now that we have MUC what about reducing the scope of the remove_dir call in purge_all_caches ? diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 5e89439..8e0a07b 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1557,7 +1557,7 @@ function purge_all_caches() { cache_helper::purge_all(); // purge all other caches: rss, simplepie, etc. - remove_dir($CFG->cachedir.'', true); + remove_dir($CFG->cachedir.''); // make sure cache dir is writable, throws exception if not make_cache_directory('');
          Hide
          Sam Hemelryk added a comment -

          Hi Matteo,

          Thanks for creating this report.

          I've had a quick try to reproduce the issue without luck. Not to much of a surprise as its definitely sounds like a race condition and they can be hard to reproduce.
          You're right the now that we have MUC we should probably look at how we are cleaning the cache direction.
          I've been looking at something similiar within the unit tests as they do the same kind of aggressive cleaning of the moodledata dir including the cache dir.
          I'll keep this in mind and expand my research of what can be done to the whole Moodle scope.

          Many thanks
          Sam

          Show
          Sam Hemelryk added a comment - Hi Matteo, Thanks for creating this report. I've had a quick try to reproduce the issue without luck. Not to much of a surprise as its definitely sounds like a race condition and they can be hard to reproduce. You're right the now that we have MUC we should probably look at how we are cleaning the cache direction. I've been looking at something similiar within the unit tests as they do the same kind of aggressive cleaning of the moodledata dir including the cache dir. I'll keep this in mind and expand my research of what can be done to the whole Moodle scope. Many thanks Sam
          Hide
          Michael de Raadt added a comment -

          A similar error was reported in MDL-38273 and I experienced the errors while testing MDL-38387.

          Show
          Michael de Raadt added a comment - A similar error was reported in MDL-38273 and I experienced the errors while testing MDL-38387 .
          Hide
          Gilles-Philippe Leblanc added a comment - - edited

          We just experiment the same behaviour when purging all the cache:

          Warning: rmdir(/path/to/moodle-master-data/cache/cachestore_file/default_application/core_string): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 Warning: rmdir(/path/to/moodle-master-data/cachestore_file/default_application/core_databasemeta): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 Warning: rmdir(/path/to/moodle-master-data/cache/cachestore_file/default_application): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 Warning: rmdir(/path/to/moodle-master-data/cachestore_file): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 
          
          Show
          Gilles-Philippe Leblanc added a comment - - edited We just experiment the same behaviour when purging all the cache: Warning: rmdir(/path/to/moodle-master-data/cache/cachestore_file/default_application/core_string): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 Warning: rmdir(/path/to/moodle-master-data/cachestore_file/default_application/core_databasemeta): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 Warning: rmdir(/path/to/moodle-master-data/cache/cachestore_file/default_application): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728 Warning: rmdir(/path/to/moodle-master-data/cachestore_file): Directory not empty in /path/to/moodle/lib/moodlelib.php on line 10728
          Hide
          Marina Glancy added a comment -

          hopefully patch will resolve MDL-41414 as well

          Show
          Marina Glancy added a comment - hopefully patch will resolve MDL-41414 as well
          Hide
          Marina Glancy added a comment -

          I just got it again. I changed the cache definition (from session to application), bumped the version, run upgrade process and here it is.

          
          ( ! ) Warning: rmdir(/home/marina/repositories/master/moodledata/cache/cachestore_file/default_application): Directory not empty in /home/marina/repositories/master/moodle/lib/moodlelib.php on line 8953
          Call Stack
          #	Time	Memory	Function	Location
          1	0.0019	369696	{main}( )	../index.php:0
          2	0.9706	25831680	upgrade_noncore( )	../index.php:422
          3	3.0105	34044544	purge_all_caches( )	../upgradelib.php:1589
          4	3.0741	34054144	remove_dir( )	../moodlelib.php:1613
          5	3.0742	34054824	remove_dir( )	../moodlelib.php:8942
          6	3.0742	34055584	remove_dir( )	../moodlelib.php:8942
          7	3.0830	34055720	rmdir ( )	../moodlelib.php:8953
          
          ( ! ) Warning: rmdir(/home/marina/repositories/master/moodledata/cache/cachestore_file): Directory not empty in /home/marina/repositories/master/moodle/lib/moodlelib.php on line 8953
          Call Stack
          #	Time	Memory	Function	Location
          1	0.0019	369696	{main}( )	../index.php:0
          2	0.9706	25831680	upgrade_noncore( )	../index.php:422
          3	3.0105	34044544	purge_all_caches( )	../upgradelib.php:1589
          4	3.0741	34054144	remove_dir( )	../moodlelib.php:1613
          5	3.0742	34054824	remove_dir( )	../moodlelib.php:8942
          6	3.0857	34054976	rmdir ( )	../moodlelib.php:8953
          
          Show
          Marina Glancy added a comment - I just got it again. I changed the cache definition (from session to application), bumped the version, run upgrade process and here it is. ( ! ) Warning: rmdir(/home/marina/repositories/master/moodledata/cache/cachestore_file/default_application): Directory not empty in /home/marina/repositories/master/moodle/lib/moodlelib.php on line 8953 Call Stack # Time Memory Function Location 1 0.0019 369696 {main}( ) ../index.php:0 2 0.9706 25831680 upgrade_noncore( ) ../index.php:422 3 3.0105 34044544 purge_all_caches( ) ../upgradelib.php:1589 4 3.0741 34054144 remove_dir( ) ../moodlelib.php:1613 5 3.0742 34054824 remove_dir( ) ../moodlelib.php:8942 6 3.0742 34055584 remove_dir( ) ../moodlelib.php:8942 7 3.0830 34055720 rmdir ( ) ../moodlelib.php:8953 ( ! ) Warning: rmdir(/home/marina/repositories/master/moodledata/cache/cachestore_file): Directory not empty in /home/marina/repositories/master/moodle/lib/moodlelib.php on line 8953 Call Stack # Time Memory Function Location 1 0.0019 369696 {main}( ) ../index.php:0 2 0.9706 25831680 upgrade_noncore( ) ../index.php:422 3 3.0105 34044544 purge_all_caches( ) ../upgradelib.php:1589 4 3.0741 34054144 remove_dir( ) ../moodlelib.php:1613 5 3.0742 34054824 remove_dir( ) ../moodlelib.php:8942 6 3.0857 34054976 rmdir ( ) ../moodlelib.php:8953

            People

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

              Dates

              • Created:
                Updated: