Moodle
  1. Moodle
  2. MDL-28605

When the Server Files Repository Has 27 subdirectories it runs out of memory

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.1.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Repositories
    • Labels:
    • Testing Instructions:
      Hide

      I have not come up with detailed instructions to reproduce this because I suspect it depends heavily on the complex directory structure which is difficult to setup.

      However, to test this fix doesn't affect anythign else (as its removign useless code)
      1/ Create a course with complex directory structure
      2/ Use the local files plugin to browse around the directories
      3/ Verify you can still navigate the struture

      Show
      I have not come up with detailed instructions to reproduce this because I suspect it depends heavily on the complex directory structure which is difficult to setup. However, to test this fix doesn't affect anythign else (as its removign useless code) 1/ Create a course with complex directory structure 2/ Use the local files plugin to browse around the directories 3/ Verify you can still navigate the struture
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Rank:
      18379

      Description

      On a site we look navigating to one of the subdirectories in the file picker using the server files plugin casues memory to run out & does not allow the user to browse the directory..

      ERROR: Invalid JSON string
      Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 227809 bytes) in /home/danp/git/moodle/lib/dml/mysqli_native_moodle_database.php on line 798

      0.0006 808128 1.

      {main}

      ()
      /home/danp/git/moodle/repository/repository_ajax.php:0
      0.1333 30824136 2. repository_local->get_listing()
      /home/danp/git/moodle/repository/repository_ajax.php:140
      2.0880 60248040 3. file_info_context_course->get_children()
      /home/danp/git/moodle/repository/local/lib.php:102
      2.9009 128389520 4. file_browser->get_file_info()
      /home/danp/git/moodle/lib/filebrowser/file_info_context_course.php:319
      2.9009 128389920 5. file_browser->get_file_info_context_module()
      /home/danp/git/moodle/lib/filebrowser/file_browser.php:90
      2.9014 128397328 6. moodle_database->get_record()
      /home/danp/git/moodle/lib/filebrowser/file_browser.php:207
      2.9014 128398184 7. moodle_database->get_record_select()
      /home/danp/git/moodle/lib/dml/moodle_database.php:1231
      2.9014 128398496 8. moodle_database->get_record_sql()
      /home/danp/git/moodle/lib/dml/moodle_database.php:1251
      2.9014 128398736 9. mysqli_native_moodle_database->get_records_sql()
      /home/danp/git/moodle/lib/dml/moodle_database.php:1279
      2.9016 128401192 10. mysqli_result->fetch_assoc()
      /home/danp/git/moodle/lib/dml/mysqli_native_moodle_database.php:798

        Activity

        Hide
        Dan Poltawski added a comment -

        I've not done anything all that thorough, but removing the useless code:

        $subdir_children = $child->get_children();

        Prevents this..

        Show
        Dan Poltawski added a comment - I've not done anything all that thorough, but removing the useless code: $subdir_children = $child->get_children(); Prevents this..
        Hide
        Michael de Raadt added a comment -

        Thanks for reporting this, Dan.

        Show
        Michael de Raadt added a comment - Thanks for reporting this, Dan.
        Hide
        Dan Poltawski added a comment -

        I don't think this issue is the root cause, but I'm submitting this fix integration as it does make a signficiant difference and is removing useless code. On a site upgraded from 1.9 this fixes the issue.

        I would like to know why the respository could ever run out of memory doing a directory listing though!

        Integrators, this can be cherry picked to 20_STABLE and master.

        Show
        Dan Poltawski added a comment - I don't think this issue is the root cause, but I'm submitting this fix integration as it does make a signficiant difference and is removing useless code. On a site upgraded from 1.9 this fixes the issue. I would like to know why the respository could ever run out of memory doing a directory listing though! Integrators, this can be cherry picked to 20_STABLE and master.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        This has been picked for master, 21_STABLE and 20_STABLE, thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - This has been picked for master, 21_STABLE and 20_STABLE, thanks!
        Hide
        Rajesh Taneja added a comment -

        Couldn't reproduce crash, with more then 35 sub-directories.
        Although, everything works fine with fix. All the files and directory structure is accessible with this patch

        Thanks for fixing this Dan

        Show
        Rajesh Taneja added a comment - Couldn't reproduce crash, with more then 35 sub-directories. Although, everything works fine with fix. All the files and directory structure is accessible with this patch Thanks for fixing this Dan
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Closing, this is now part of Moodle. Big thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Closing, this is now part of Moodle. Big thanks!

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: