Taks Schedule (session:gc) enabled
Session table '#__session' entries shall delete if session time is older than time-limit
Nothing happens, database table grows over time massively
In the plugin code, nothing happens if session_handler is set to 'database'
But that is odd because it leads to a massive grow of the table over time and that slows the admin panel (because of loggedin-users module)
See in code:
if ($this->getApplication()->get('session_handler', 'none') !== 'database' && $enableMetadata) {
$this->metadataManager->deletePriorTo(time() - $this->getApplication()->getSession()->getExpire());
}
Labels |
Added:
No Code Attached Yet
|
Yes, it is enabled. But as far as my understanding of the plugin, that parameter will not be used anyway. Isn't it?
We store both session and session meta data in the same table #__sessions. So in case you are using database handler, the session meta data is also deleted in gc process of the session handler, that's the reason we have $this->getApplication()->get('session_handler', 'none') !== 'database'
in the code.
If you have the parameter set to Yes but data is still not being deleted, something strange is happening here.
The problem is, that due to the !== statement, if you have database as session_handler, this GC in the metadata is never executed!
It is deleted in session GC because the session metadata is stored in same table with session data. Basically, the code here https://github.com/joomla/joomla-cms/blob/5.2-dev/plugins/task/sessiongc/src/Extension/SessionGC.php#L107 will delete both session and session meta data in case you use database as session handler.
I only can say that the session_table is growing over time for whatever reasons and that will lead to problems with the site performance.
When you search the net for others haveing the same problem, we are not the only ones having that issue.
Can you describe which functions creates records in the session_table and what mechanism you think controls the size of that table?
The main logic is handled inside this file libraries/vendor/joomla/session/src/Handler/DatabaseHandler.php. About the data clean up, it is being handled inside close
method in that class.
Maybe you should try to execute the task manually, then check if size of session table reduced after that?
Inside the function "close" there is this if statement: if ($this->gcCalled) {
$this->gcCalled is false even if the task in scheduler is executed. So the delete functionality is not executed inside that methodß
When the task is executed, the method gc
inside the class is executed and $this->gcCalled
set to true
there, so I do not know why it is false in your case
I tried to add a simple code to close method and can confirm the query is executed, so no clue why it is not working on your site.
Is the PHP setting session.gcprobabiltity relevant for the execution?
What code snippet do you insert to get gcCalled set to true? Maybe I can reproduce
Is the PHP setting session.gcprobabiltity relevant for the execution?
It is not relevant for schedule task
What code snippet do you insert to get gcCalled set to true? Maybe I can reproduce
I do not use any code snippet. I just went to System -> Schedule Tasks, click on Run Test button for Session GC
task to run the task and the code is executed.
It is interesting that the Test run is not working because it says another task is running... but it is the same old GC taks which is obviously finished.
/**
* Placeholder result, but the idea is if we failed to fetch the task, it's likely because another task was
* already running. This is a fair assumption if this test run was triggered through the administrator backend,
* so we know the task probably exists and is either enabled/disabled (not trashed).
*/
Sorry, I do not understand how task schedule works internal, so I could not comment on that. So if the task is executed properly, the session data will be deleted as expected. If it is not executed properly for some reasons, something wrong with task schedule here.
Ok, i found the reason for the issue. It is that a previous task in scheduler is marked as still running (in my case the Joomla update notification). The issue shoud be related to not correctly marked a task as finished executed. Hope someone with knowledge about the task scheduler can help
@sentixGmbH can you share a snippet of the joomla_scheduler.php log ?
Labels |
Added:
Information Required
|
@sentixGmbH Could you please send the information @alikon asked above?
#Fields: date time priority message
2025-02-16 12:10:27 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-16 12:10:27 INFO Aufgabe> SessionGC end
2025-02-16 12:10:27 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-16 13:09:31 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-16 13:09:31 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.40 (net 0.40) Sekunden.
2025-02-17 12:53:07 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-17 12:53:07 INFO Aufgabe> SessionGC end
2025-02-17 12:53:07 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-18 10:32:18 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-18 10:32:19 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.83 (net 0.83) Sekunden.
2025-02-18 14:26:31 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-18 14:26:31 INFO Aufgabe> SessionGC end
2025-02-18 14:26:31 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-19 13:43:24 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-19 13:43:25 INFO Aufgabe> UpdateNotification end
2025-02-19 13:43:25 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.68 (net 0.68) Sekunden.
2025-02-19 18:12:34 INFO Running task#02 'Session GC'.
2025-02-19 18:12:34 INFO Task> SessionGC end
2025-02-19 18:12:34 INFO Successfully finished task#02 in 0.00 (net 0.00) seconds.
2025-02-20 22:53:05 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-20 22:53:05 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.34 (net 0.34) Sekunden.
2025-02-21 05:16:04 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-21 05:16:04 INFO Aufgabe> SessionGC end
2025-02-21 05:16:04 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-22 09:20:29 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-22 09:20:29 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.34 (net 0.34) Sekunden.
2025-02-23 11:07:32 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-23 11:07:32 INFO Aufgabe> SessionGC end
2025-02-23 11:07:32 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-23 18:43:54 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-23 18:43:54 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.46 (net 0.46) Sekunden.
2025-02-24 11:47:25 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-24 11:47:25 INFO Aufgabe> SessionGC end
2025-02-24 11:47:25 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-24 21:38:27 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-24 21:38:27 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.23 (net 0.23) Sekunden.
2025-02-25 13:48:37 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-25 13:48:37 INFO Aufgabe> SessionGC end
2025-02-25 13:48:37 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-26 06:21:28 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-26 06:21:29 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.31 (net 0.31) Sekunden.
2025-02-26 15:36:01 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-26 15:36:01 INFO Aufgabe> SessionGC end
2025-02-26 15:36:01 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-02-27 16:05:02 INFO Laufende Aufgabe#03 'Update Notification'.
2025-02-27 16:05:03 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.51 (net 0.51) Sekunden.
2025-02-27 22:10:44 INFO Laufende Aufgabe#02 'Session GC'.
2025-02-27 22:10:44 INFO Aufgabe> SessionGC end
2025-02-27 22:10:44 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-02 20:41:59 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-02 20:42:00 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.58 (net 0.58) Sekunden.
2025-03-03 03:41:07 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-03 03:41:07 INFO Aufgabe> SessionGC end
2025-03-03 03:41:07 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-04 02:38:52 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-04 02:38:53 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.32 (net 0.32) Sekunden.
2025-03-04 08:18:57 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-04 08:18:57 INFO Aufgabe> SessionGC end
2025-03-04 08:18:57 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-05 09:14:04 INFO Running task#03 'Update Notification'.
2025-03-05 09:14:05 INFO Successfully finished task#03 in 0.43 (net 0.43) seconds.
2025-03-05 21:54:06 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-05 21:54:06 INFO Aufgabe> SessionGC end
2025-03-05 21:54:06 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-07 06:04:38 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-07 06:04:38 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.35 (net 0.35) Sekunden.
2025-03-07 17:39:49 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-07 17:39:49 INFO Aufgabe> SessionGC end
2025-03-07 17:39:49 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-08 13:20:55 INFO Running task#03 'Update Notification'.
2025-03-08 13:20:56 INFO Successfully finished task#03 in 0.35 (net 0.35) seconds.
2025-03-09 16:08:52 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-09 16:08:52 INFO Aufgabe> SessionGC end
2025-03-09 16:08:52 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-10 07:50:13 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-10 07:50:13 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.34 (net 0.34) Sekunden.
2025-03-10 19:16:33 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-10 19:16:33 INFO Aufgabe> SessionGC end
2025-03-10 19:16:33 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-13 05:18:59 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-13 05:19:00 INFO Aufgabe> UpdateNotification end
2025-03-13 05:19:00 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.59 (net 0.59) Sekunden.
2025-03-13 05:20:29 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-13 05:20:29 INFO Aufgabe> SessionGC end
2025-03-13 05:20:29 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-14 14:05:03 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-14 14:05:04 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.45 (net 0.45) Sekunden.
2025-03-15 07:25:14 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-15 07:25:14 INFO Aufgabe> SessionGC end
2025-03-15 07:25:14 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-16 10:57:26 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-16 10:57:26 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.37 (net 0.37) Sekunden.
2025-03-16 20:11:18 INFO Laufende Aufgabe#02 'Session GC'.
2025-03-16 20:11:18 INFO Aufgabe> SessionGC end
2025-03-16 20:11:18 INFO Erfolgreich abgeschlossene Aufgabe#02 in 0.00 (net 0.00) Sekunden.
2025-03-17 17:36:36 INFO Laufende Aufgabe#03 'Update Notification'.
2025-03-17 17:36:37 INFO Erfolgreich abgeschlossene Aufgabe#03 in 0.44 (net 0.44) Sekunden.
2025-03-17 17:36:48 INFO Laufende Aufgabe#01 'Rotate Logs'.
Do you have Enable Session Data Cleanup parameter of the task set to Yes ? I think set that parameter to Yes should solve the issue. But Yes, look like there is a small issue with the code handle deleting session meta data here.