Conversation
…ump threads on a start-up hang ServletRegistrationSingleton.activate() called WebContainer.createDefaultSharedHttpContext(), which pax-web runs on its single configuration thread. SCR holds the component's state lock during activate(), while the configuration thread, registering WebContainer, waits for that same lock to activate ServletComponent. SCR broke the cycle after ds.lock.timeout with "Could not obtain lock", and start-up never reached "OpenIDM ready". Create the context on first use without holding a lock, and in CI take a jcmd thread dump when OpenIDM does not become ready within the timeout. Fixes OpenIdentityPlatform#228
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #228
Problem
ui-smoke-tests (17, /myidm, samples/usecase/usecase1)in run 35873142464 (attempt 1) did not just log an extra SCR error: OpenIDM never became ready.Start OpenIDMwaited 3 minutes forOpenIDM ready, the log stopped at theCould not obtain lockerror, and the UI tests never ran. The log line after the stack trace names the reference that timed out:api-servlet(19) : Could not get service from ref [ServletRegistration]. That reference isServletRegistrationSingleton, not the auth filter suggested in the issue.The cause is a lock cycle between Felix SCR and pax-web 11:
WebContainer(Activator.performConfiguration). SCR then activatesServletRegistrationSingleton, which registersServletRegistration, and synchronously activatesServletComponent.ServletComponentwaits forServletRegistrationSingleton's SCR state lock.ServletRegistrationholds that state lock whileactivate()runs (SingleComponentManager.getServiceInternal).activate()calledwebContainer.createDefaultSharedHttpContext(), which callsServerModel.run(task, false). From any thread other than the configuration thread, that call queues the task on the same executor and blocks infuture.get()with no timeout.SCR breaks the cycle only on the pax-web side, after
ds.lock.timeout(5 s). This matches the log: Jetty started at 23:43:42 and the error was logged at 23:43:47. Theactivate()call came in with the move to pax-web 11 (#114).Changes
ServletRegistrationSingletoncreates the sharedHttpContexton first use (registerServlet,getContext, filter registration) instead of inactivate(). It holds no lock while it does so: holding a monitor across the pax-web call would rebuild the same cycle, this time without a timeout. If two threads create the context at the same time, the second one is discarded (AtomicReference.compareAndSet).Test on Unix,Start OpenIDM): ifOpenIDM readydoes not appear within the timeout, runjcmd <pid> Thread.print -land print the output, and save it toopenidm/logs/threaddump-<pid>.txt(included in the failure artifact).Not covered
The log does not show which thread held the state lock, and it does not explain why start-up stayed stuck after the 5 s timeout: no further error was logged, so something waits without a timeout. The thread dump added to CI is meant to answer both questions the next time this happens.
Tests
ServletRegistrationSingletonTest:activate()does not callWebContainer. This test fails on master withNoInteractionsWanted.registerServletuses it.