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

Fix for deactivating managed context in GraphQL server #27040

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

phillip-kruger
Copy link
Member

Fix #27036

Signed-off-by: Phillip Kruger [email protected]

@quarkus-bot
Copy link

quarkus-bot bot commented Aug 1, 2022

Failing Jobs - Building 308aae0

Status Name Step Failures Logs Raw logs
Gradle Tests - JDK 11 Build Failures Logs Raw logs
✔️ Gradle Tests - JDK 11 Windows

Full information is available in the Build summary check run.

Failures

⚙️ Gradle Tests - JDK 11 #

- Failing: integration-tests/gradle 

📦 integration-tests/gradle

io.quarkus.gradle.devmode.CompositeBuildWithDependenciesDevModeTest.main line 24 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in io.quarkus.test.devmode.util.DevModeTestUtils that uses java.util.function.Supplier, java.util.function.Supplierjava.util.concurrent.atomic.AtomicReference, java.util.concurrent.atomic.AtomicReferencejava.lang.String, java.lang.Stringboolean was not fulfilled within 1 minutes.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

@phillip-kruger phillip-kruger added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 1, 2022
@geoand geoand merged commit 058ef90 into quarkusio:main Aug 1, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 1, 2022
@quarkus-bot quarkus-bot bot added this to the 2.12 - main milestone Aug 1, 2022
@@ -67,6 +68,7 @@ public void handle(final RoutingContext ctx) {
}
try {
handleWithIdentity(ctx);
currentManagedContext.deactivate();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this one in a finally? Why deactivate in one case and terminate in the case of an exception?

Also what's the purpose of this.currentManagedContextTerminationHandler now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.currentManagedContextTerminationHandler will terminate (so deactivate and destroy) once we are done, while the deactivate after the handleWithIdentity will only deactivate (so that it does not leak)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not need to be in a finally as the catch with terminate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can understand that but my concern was more that we are not consistent. Typically here: https://github.com/quarkusio/quarkus/pull/27040/files#diff-5b5cda47e6a5418c9345a577d468f058e05c412dc9b64fce6a6ef5aec496023bR75-R85 where we simply deactivate. Or maybe the exception from the latter is caught below?

Also what do you mean by leaking? What I don't understand is how we can leak something between this and the end of the response? Or is it that the thread is somehow reused between the end of this and the end of the response?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thread could be reused, in a high traffic scenario.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you're sure that all the response handlers we added earlier are always executed on the right thread at the right time?
That's what gets me a bit worried.

Note that I have no idea how this all works so I'm asking naive questions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sure. Maybe @stuartwdouglas can explain better. By leaking I mean that a new request that use the same thread can get the context that still float around (because it's not been deactivated)

@gsmet gsmet modified the milestones: 2.12 - main, 2.11.2.Final Aug 3, 2022
@gsmet gsmet changed the title Fix for deactivating managed context Fix for deactivating managed context in GraphQL server Aug 3, 2022
@gsmet gsmet modified the milestones: 2.11.2.Final, 2.10.5.Final Aug 3, 2022
@phillip-kruger phillip-kruger deleted the graphql-auth-issue branch June 13, 2023 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL spurious authentication failures
4 participants