Bug #14916
closedDeadlock between WebSession mutex and servlet session lock during unload request and session invalidation
0%
Description
A JWt request triggered by the browser’s Beacon-based page-unload signal (see #14709) can deadlock with session invalidation while the server is shutting down.
In GDP's UI tests, the unload request can still be processing when UIServerExtension.afterEach() calls Server.stop(). The thread dump (10597_jetty.txt) shows this lock cycle:
- The unload-request thread holds the JWt
WebSessionmutex whileWebSession.handleRequest()flushes its response. During the flush, Jetty commits the session and waits for the Jetty session lock. - A second request thread invalidates the session. Jetty invokes
WtServlet.BoundSession.valueUnbound()while handling invalidation; JWt callsWebSession.destruct(), which waits for theWebSessionmutex while the Jetty session lock is held. - The test thread stopping the server also waits for the Jetty session lock.
The relevant stacks include WebSession.Handler.flushResponse() → WebSession.handleRequest() → Jetty session commit on one thread, and ManagedSession.finishInvalidate() → BoundSession.valueUnbound() → WebSession.destruct() on the other.
We observed the same lock cycle with Jetty 11 and Jetty 12, although the Jetty stack frames differ. This suggests the issue is the lock ordering between JWt request handling and session-unbind cleanup, rather than a Jetty-version-specific regression.
Files
RM Updated by Romain Mardulyn 12 days ago
- Status changed from New to InProgress
- Assignee set to Raf Pauwels
RM Updated by Romain Mardulyn 12 days ago
- Status changed from InProgress to Review
- Assignee changed from Raf Pauwels to Romain Mardulyn
RM Updated by Romain Mardulyn 12 days ago
- Status changed from Review to Resolved
- Assignee changed from Romain Mardulyn to Raf Pauwels
- Target version set to 4.15.0
RM Updated by Romain Mardulyn 11 days ago
- Status changed from Resolved to Implemented @Emweb
RM Updated by Romain Mardulyn 10 days ago
- Status changed from Implemented @Emweb to Closed