-
Notifications
You must be signed in to change notification settings - Fork 339
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
Deadlock when using subscriptions with two Ktor worker threads #1895
Comments
Hello 👋 class MyKtorGraphQLServer(
requestParser: KtorGraphQLRequestParser,
contextFactory: KtorGraphQLContextFactory,
requestHandler: GraphQLRequestHandler
) : KtorGraphQLServer(requestParser, contextFactory, requestHandler) {
override suspend fun execute(request: ServerRequest): GraphQLServerResponse? = withContext(Dispatchers.Default) {
super.execute(request)
}
} |
Thanks for the reply! Looks promising but unfortunately I find no way to override Also, would that really solve the problem for subscriptions which is using |
Good callout. I'll open up a separate issue to allow folks specifying their own GraphQL server impls. |
Opened up #1902 |
Library Version
7.0.2
Describe the bug
A deadlock occurs when calling subscriptions in
graphql-kotlin-ktor-server
if a suspendable function is called (that actually suspends execution) when there are only two workers (workerGroupSize
is set to 2 inapplication.conf
or using default settings on a machine with 2 CPUs). Tested with Netty as engine.Explicitly setting
workerGroupSize
to 3 or higher seems to fix the problem but might not be optimal on machines with only 2 CPUs. Problem surfaced on AWS Elastic Container Service with ECS instance reporting to have 2 CPUs (even with different vCPU values).To Reproduce
I created a minimal reproducible example here and this is how it can be reproduced:
./gradlew run
ws://localhost:8080/subscriptions
{"type":"connection_init"}
{"type":"subscribe", "id":"12345", "payload": {"query": "subscription { random }" } }
eventLoopGroupProxy
) has stateWAITING
Expected behavior
Subscriptions work even with "only" two worker threads
The text was updated successfully, but these errors were encountered: