Skip to content

[Regression] Multi-threaded access to discover types throws "The given key was not present in the dictionary" exception #8433

@vypsim

Description

@vypsim

Product

Hot Chocolate

Version

15.1.4

Steps to reproduce

When upgrading from HotChocolate v15.1.3 to v15.1.4 we started encountering an issue with our integration tests.

To give you a bit background, we use WebApplicationFactory with parallel test execution.

After upgrading to v15.1.4 whenever the tests are run in parallel, random tests fail with the same error message in the log below, but with random different fields (sometimes for the same test).

I wonder if this is some sort of a race condition or locking that's changed which is causing multiple threads to access the same dictionary during setup.

Apologies for not providing a re-production, but it's a hard scenario to re-produce, I was hoping you might have some ideas based on the changes that went between those 2 versions.

Can you please advise.

Thanks.

What is expected?

For the tests to run without HotChocolate erroring out.

What is actually happening?

HotChocolate is erroring out.

Relevant log output

Message: 
  HotChocolate.SchemaException : For more details look at the `Errors` property.
  
  1. The given key 'System.String id' was not present in the dictionary. (Beacon.API.Assets.GraphQL.QueryType)
  

Stack Trace: 
  TypeInitializer.DiscoverTypes()
  TypeInitializer.Initialize()
  Setup.InitializeTypes(SchemaBuilder builder, IDescriptorContext context, IReadOnlyList`1 types)
  Setup.Create(SchemaBuilder builder, LazySchema lazySchema, IDescriptorContext context)
  SchemaBuilder.Create(IDescriptorContext context)
  ISchemaBuilder.Create(IDescriptorContext context)
  RequestExecutorResolver.CreateSchemaAsync(ConfigurationContext context, RequestExecutorSetup setup, RequestExecutorOptions executorOptions, IServiceProvider schemaServices, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken)
  RequestExecutorResolver.CreateSchemaServicesAsync(ConfigurationContext context, RequestExecutorSetup setup, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken)
  RequestExecutorResolver.CreateRequestExecutorAsync(String schemaName, Boolean isInitialCreation, CancellationToken cancellationToken)
  RequestExecutorResolver.GetRequestExecutorAsync(String schemaName, CancellationToken cancellationToken)  RequestExecutorResolver.WarmupAsync.__WarmupSchemaAsync|40_0(string schemaName, System.Threading.CancellationToken cancellationToken)	Unknown
  RequestExecutorResolver.WarmupAsync(System.Threading.CancellationToken cancellationToken)	Unknown
  RequestExecutorWarmupService.StartAsync(System.Threading.CancellationToken cancellationToken)

Additional context

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions