Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orphaned sessions are never deleted at runtime in the SessionDataStore. #12705

Closed
mwgmnn opened this issue Jan 13, 2025 · 1 comment · Fixed by #12708
Closed

Orphaned sessions are never deleted at runtime in the SessionDataStore. #12705

mwgmnn opened this issue Jan 13, 2025 · 1 comment · Fixed by #12708
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@mwgmnn
Copy link
Contributor

mwgmnn commented Jan 13, 2025

Jetty version(s)
Jetty 12.0.5

Jetty Environment
ee10

Java version/vendor (use: java -version)
openjdk 21.0.2

OS type/version
Windows 11

Description
When using the (JDBC)SessionDataStore the orphaned sessions are deleted only on server restart, never at runtime. I tracked it down to org.eclipse.jetty.session.AbstractSessionDataStore, line 297 ff. The field _lastOrphanSweepTime is always set to the current time, even if the if condition is false. The default scavenge interval is 10 min and so _gracePeriodSec needs to be < 1 min for entering cleanOrphans. But by default it is 1 hr.

I suggest to insert the try { } catch under the if statement like this:

if (now > (_lastOrphanSweepTime + TimeUnit.SECONDS.toMillis(10 * _gracePeriodSec)))
{
    try
    {
        if (LOG.isDebugEnabled())
            LOG.debug("Cleaning orphans at {}, last sweep at {}", now, _lastOrphanSweepTime);
               
        cleanOrphans(now - TimeUnit.SECONDS.toMillis(10 * _gracePeriodSec));
    }
    finally
    {
        _lastOrphanSweepTime = now;
    }
}

How to reproduce?
Reproducable when using the JDBCSessionDataStore with default grace period and default scavenge interval of the housekeeper.

@mwgmnn mwgmnn added the Bug For general bugs on Jetty side label Jan 13, 2025
@janbartel janbartel self-assigned this Jan 14, 2025
janbartel added a commit that referenced this issue Jan 14, 2025
@janbartel
Copy link
Contributor

@mwgmnn can you checkout the branch in the PR #12708 and see if it fixes your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants