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

Problems when MUC is configured to store session cache in other store and not in default user session - bloating, abscence of prefix, etc

XMLWordPrintable

    • MOODLE_30_STABLE
    • Hide
      1. Load Moodle set user selections to file based cache
      2. go to categories page
      3. expand a category
      4. reload the page.
      5. ensure that same category is still expanded.
      6. log out
      7. log in as an admin
      8. go to the tasks and run the 'cache_cron_task' task.
      9. Verify on the filesystem that the cache has been removed.
      Show
      Load Moodle set user selections to file based cache go to categories page expand a category reload the page. ensure that same category is still expanded. log out log in as an admin go to the tasks and run the 'cache_cron_task' task. Verify on the filesystem that the cache has been removed.

      Background: There appears to be a trend of more cached data being stored in the session. Usually this is classified as session bloat and is bad, but the counter argument to this is that MUC can be configured to use a different cache store to offload this bloat from the user's session which must be loaded on every page. This seems reasonable so I started to research if I could update our Redis cache store to store session cache.

      (Problem 1) The first thing that came to mind when trying to implement this, is that I was worried about stale data filling the Redis server (EG: user doesn't actually log out). I found \cache_helper::clean_old_session_data which is supposed solve this very problem. Unfortunately, I don't think it works because it searches for keys with the prefix of cache_session::KEY_PREFIX but cache_session::KEY_PREFIX is never used for key prefixes. In addition, I'm not sure how it actually determines which keys to delete. It appears to expect all the key values to be an array with a lastaccess key, but in my light testing, none of the key values have this.

      (Problem 2) In addition, while I was investigating the key prefix for sessions, I found that, under normal circumstances, I'm not seeing the sessionid in the key prefix. This is because \cache_session::set_session_id is not called unless something odd/bad happens like switching users. This results in keys in Redis with the names like, "u2__67af9b6f1ef69552fc8b87b2c3e7537187ded2c7" instead of "u2_mySessionId_67af9b6f1ef69552fc8b87b2c3e7537187ded2c7"

      (Problem 3) Looks like session cache is not purged on logout. Seems like a reasonable time to purge them. There is a \cache_session::purge_current_user method that could be called. This might help to free up memory sooner instead of having to depend on the cron.

            Unassigned Unassigned
            bushido Mark Nielsen
            Frédéric Massart Frédéric Massart
            Votes:
            9 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.