With database-stored sessions, the cf_sessions_data table is not cleaned automatically

Description

I thought I had read somewhere that Lucee would prune / trim / clean the cf_sessions_data table automatically. However, after running with database-backed sessions for several weeks, the table grew to be very large, with 99% of the records having expires according to the expires column.

We have created a scheduled task to clean the table, but we shouldn’t have to do that.

FWIW, I can’t find any table cleanup in the code on the 5.4, 6.0, or 6.1 branches.

 

Possibly related discussion: https://dev.lucee.org/t/client-variables-database-millions-of-entries/8520/1

Environment

Docker or just installed on CentOS 7 server

Activity

Show:

Zac Spitzer 26 March 2025 at 09:06
Edited

the interval for purging datasource sessions is only once per hour

but the core problem is, the cleaner only processes thru admin defined datasources, if the datasource is defined in the application.cfc it’s not currently being purged

https://github.com/lucee/Lucee/blob/6.2/core/src/main/java/lucee/runtime/type/scope/storage/clean/DatasourceStorageScopeCleaner.java#L55

WORKAROUND

If you are defining the session storage datasource via application.cfc just add a datasource pointing to that same schema via the admin, with the storage flag enabled and Lucee will purge the expired sessions hourly

Pothys - MitrahSoft 25 October 2024 at 12:40

, I have investigated this ticket on Lucee versions 6.0.3.1-SNAPSHOT and 6.2.0.130-SNAPSHOT with Docker and confirmed that the issue occurred. When I try to set session data after enabling sessionManagement and sessionStorage as dataSources with this.sessionTimeout = createTimeSpan(0, 0, 1, 0), I notice that the expiry data is not cleared in the cf_session_data table after 1 minute. However, it does clear the data after restarting Docker.

Leon Miller-Out 14 June 2024 at 19:48

@Pothys, unfortunately it's not easy for me to test that right now. Sorry!

Pothys - MitrahSoft 4 June 2024 at 13:34

Could you please try with the Lucee version 6.1.0.175-SNAPSHOT and report back here?

Zac Spitzer 2 May 2024 at 08:37
Edited

the controller background threads calls this code

https://github.com/lucee/Lucee/blob/6.1/core/src/main/java/lucee/runtime/type/scope/ScopeContext.java#L776

if you bump the log level up for the scope.log, you should see all the activity in this area

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Affects versions

Created 1 May 2024 at 21:41
Updated 26 March 2025 at 15:30