-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
3.0
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.
- has a non-specific relationship to
-
MDL-58018 Reduce session lock contention with opt-in READ_ONLY_SESSION
- Closed