Multiplexing: ConnectorTypeMapping isn't thread-safe (since preview5)
See original GitHub issueTypeMapping seems very broken since preview 5
System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Npgsql.TypeMapping.ConnectorTypeMapper.Bind(NpgsqlTypeHandler handler, PostgresType pgType, Nullable`1 npgsqlDbType, Type[] clrTypes)
at Npgsql.TypeMapping.ConnectorTypeMapper.Bind(NpgsqlTypeMapping mapping, PostgresType pgType)
at Npgsql.TypeMapping.ConnectorTypeMapper.BindArray(NpgsqlTypeMapping elementMapping)
at Npgsql.TypeMapping.ConnectorTypeMapper.GetByClrType(Type type)
at Npgsql.NpgsqlParameter.ResolveHandler(ConnectorTypeMapper typeMapper)
at Npgsql.NpgsqlCommand.ValidateParameters(ConnectorTypeMapper typeMapper)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at Npgsql.TypeMapping.ConnectorTypeMapper.Bind(NpgsqlTypeHandler handler, PostgresType pgType, Nullable`1 npgsqlDbType, Type[] clrTypes)
at Npgsql.TypeMapping.ConnectorTypeMapper.Bind(NpgsqlTypeMapping mapping, PostgresType pgType)
at Npgsql.TypeMapping.ConnectorTypeMapper.BindArray(NpgsqlTypeMapping elementMapping)
at Npgsql.TypeMapping.ConnectorTypeMapper.GetByClrType(Type type)
at Npgsql.NpgsqlParameter.ResolveHandler(ConnectorTypeMapper typeMapper)
at Npgsql.NpgsqlCommand.ValidateParameters(ConnectorTypeMapper typeMapper)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
and other fun manifestations of concurrent inits. preview4 is ok so it must be one of the AOT preparation PRs that caused this.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to prove that HashMap in java is not thread-safe
A hash map is based on an array, where each item represents a bucket. ... So theoretically it is proven that HashMap is...
Read more >Ensuring the thread-safety of the entire codebase : r/java
I just encountered a bug where my non-thread safe cache implementation caused race conditions due to a piece of code way up the...
Read more >What Is Thread-Safety and How to Achieve It?
This means that different threads can access the same resources without exposing erroneous behavior or producing unpredictable results.
Read more >Lettuce Reference Guide
Lettuce is a scalable thread-safe Redis client based on netty and Reactor. Lettuce provides synchronous, asynchronous and reactive APIs to interact with Redis....
Read more >Changelog
BUILD: cfgparse: Fix GCC warning about a variable used after realloc ... reads too far when no port nor path - BUG/MEDIUM: mux-h1:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, I found the problem -
MultiplexingConnectorPool.MultiplexingTypeMapper
is used by every command on the same pool, and sinceConnectorTypeMapper
isn’t thread safe…As discussed offline, we should try to avoid having another TypeMapper just for multiplexing - just using ConcurrentDictionary in ConnectorTypeMapper may be good enough (also need to pay attention to racing bindings)