Skip to content

Conversation

dbelouslv
Copy link

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.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at MySql.Data.MySqlClient.MySqlPoolManager.GetPoolAsync(MySqlConnectionStringBuilder settings, Boolean execAsync, CancellationToken cancellationToken) at MySql.Data.MySqlClient.MySqlConnection.OpenAsync(Boolean execAsync, CancellationToken cancellationToken) at MySql.Data.MySqlClient.MySqlConnection.Open().

Use Concurrent Collections: In a multi-threaded environment, it's best to use concurrent collections that are designed to be thread-safe. In .NET, you have access to collections like ConcurrentDictionary and ConcurrentQueue which are designed for concurrent access.

Replace your regular Dictionary with a ConcurrentDictionary. This should help prevent concurrent update issues.

@mysql-oca-bot
Copy link

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@dbelouslv
Copy link
Author

@mysql-oca-bot - "You successfully signed an OCA. As a next step, Oracle will review your OCA submission."

@bgrainger
Copy link

This crash was already fixed here: #56.

@nick-asher
Copy link

As of MySql.Data version 8.1.0 via a dependency on MySql.EntityFrameworkCore, the crash has not been fixed. Swapping to a ConcurrentDictionary seems like a sensible change?

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@dbelouslv
Copy link
Author

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=112715 for updates.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants