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

BulkExtensions determines target DbContext incorrectly when calls to different database servers in parallel #1491

Open
micaelle opened this issue May 16, 2024 · 1 comment

Comments

@micaelle
Copy link

micaelle commented May 16, 2024

I have a test code which calls some Bulk-method (BulkInsertOrUpdateAsync for instance). And when I launching this test in parallel for different db servers (MsSql and PostgreSql) it send queries to wrong targets - PostgreSql-queries to the MsSql server or, vice versa, MsSql-queries to Postgres.

This looks like issue #964, the error message is the same.

The root cause is database type have determined in static class (SqlAdaptersMapping.DbServer) and this works incorrect in parallel execution.

Async lock around of Bulk* calls was the solution for me. But seems this behavior may lead to complex bugs in multi-server configurations. Probably will valuable to mention that in readme, at least?

@micaelle micaelle changed the title BulkExtensions determine target DbContext incorrect when parallel calls to different database servers BulkExtensions determines target DbContext incorrectly when calls to different database servers in parallel May 16, 2024
@b4icurmt
Copy link

I encounter the same situation. I have different tests running using different kinds of DB servers. The error I get is System.InvalidCastException : Unable to cast object of type 'Microsoft.Data.Sqlite.SqliteConnection' to type 'Microsoft.Data.SqlClient.SqlConnection'.

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

No branches or pull requests

2 participants