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

Many Merge/Read SQL operations inside one transaction raise exception that temp table already exists #1426

Open
dimonchelli-dev opened this issue Mar 4, 2024 · 0 comments

Comments

@dimonchelli-dev
Copy link

dimonchelli-dev commented Mar 4, 2024

Version:
Problem was discovered due to version update from 6.5.6 to 8.0.2

Problem:
If we have many Merge/Read operations with the same entity type inside one transaction, then an exception will occur.
Microsoft.Data.SqlClient.SqlException (0x80131904): There is already an object named '#SomeEntityTemp' in the database
Config:

BulkConfig
{
    ...
    UseTempDB=true,
    UniqueTableNameTempDb=false,
    ...
}

Reason:
Some optimizations were done in code not to do extra db query execution call in case of usage of temp db.
It didn't work properly in case of multiple requests for entities of same type with config above because temp table name generation depends on entity type.
The possible solution is to use UniqueTableNameTempDb=true, but it is not optimal due to SQL Server query plan caching.

if (!tableInfo.BulkConfig.UseTempDB) // When UseTempDB is set temp tables are automaticaly dropped by Db


and maybe in other adapters
image

@dimonchelli-dev dimonchelli-dev changed the title Many Merge/Read SQL operations inside one transaction raise exception that temp temple already exists Many Merge/Read SQL operations inside one transaction raise exception that temp table already exists Mar 4, 2024
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

1 participant