No Code Attached Yet Information Required
avatar sentixGmbH
sentixGmbH
28 Feb 2025

Steps to reproduce the issue

Taks Schedule (session:gc) enabled

Expected result

Session table '#__session' entries shall delete if session time is older than time-limit

Actual result

Nothing happens, database table grows over time massively

System information (as much as possible)

Additional comments

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());
}

avatar sentixGmbH sentixGmbH - open - 28 Feb 2025
avatar joomla-cms-bot joomla-cms-bot - change - 28 Feb 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 28 Feb 2025
avatar joomdonation
joomdonation - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

Yes, it is enabled. But as far as my understanding of the plugin, that parameter will not be used anyway. Isn't it?

avatar joomdonation
joomdonation - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

The problem is, that due to the !== statement, if you have database as session_handler, this GC in the metadata is never executed!

avatar joomdonation
joomdonation - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

Can you describe which functions creates records in the session_table and what mechanism you think controls the size of that table?

avatar joomdonation
joomdonation - comment - 28 Feb 2025

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?

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

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ß

avatar joomdonation
joomdonation - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

Is the PHP setting session.gcprobabiltity relevant for the execution?

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

What code snippet do you insert to get gcCalled set to true? Maybe I can reproduce

avatar joomdonation
joomdonation - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

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).
*/

avatar joomdonation
joomdonation - comment - 28 Feb 2025

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.

avatar sentixGmbH
sentixGmbH - comment - 28 Feb 2025

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

avatar alikon
alikon - comment - 2 Mar 2025

@sentixGmbH can you share a snippet of the joomla_scheduler.php log ?

avatar alikon alikon - change - 2 Mar 2025
Labels Added: Information Required
avatar alikon alikon - labeled - 2 Mar 2025
avatar joomdonation
joomdonation - comment - 21 Mar 2025

@sentixGmbH Could you please send the information @alikon asked above?

avatar sentixGmbH
sentixGmbH - comment - 21 Mar 2025

#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'.

Add a Comment

Login with GitHub to post a comment