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

SqliteTransaction.Dispose() leaves an orphaned transaction instance in the connection if RollbackInternal() throws #25119

Closed
mmthomas opened this issue Jun 17, 2021 · 0 comments · Fixed by #32605
Labels
area-adonet-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported poachable punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Milestone

Comments

@mmthomas
Copy link

mmthomas commented Jun 17, 2021

If the underling sqlite provider throws during a call to SqliteTransaction.Dispose(), then SqliteTransaction.Complete() is never called, and the transaction instance is left orphaned in the connection. This prevents any further transactions from being started on the connection.

I expect that the even if SqliteTransaction.RollbackInternal() throws, SqliteTransaction.Complete() is still called to clean up the connection before the exception leaves the Dispose() call frame.

The scenario where this may occur is with removable or network storage, where the storage the database file resides on has been removed or is otherwise unavailable just before a transaction is aborted/disposed for some reason. If access to the storage location is later restored, I would expect to be able to re-use the connection instance to issue new transactions against the database file.

repro project:

SqliteTransactionDisposeRepro.zip

version information

Microsoft.Data.Sqlite version: <= 5.0.7
Target framework: all targets
Operating system: all OS

@mmthomas mmthomas changed the title SqliteTransaction.Dispose() leaves an orphaned transaction instance in the connection if InternalRollback() throws SqliteTransaction.Dispose() leaves an orphaned transaction instance in the connection if RollbackInternal() throws Jun 17, 2021
@AndriySvyryd AndriySvyryd added this to the 6.0.0 milestone Jun 18, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0, Backlog Sep 24, 2021
@ajcvickers ajcvickers modified the milestones: Backlog, 7.0.0 Nov 10, 2021
@ajcvickers ajcvickers added the punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. label Sep 13, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Sep 13, 2022
@bricelam bricelam removed their assignment Jul 8, 2023
@ajcvickers ajcvickers self-assigned this Dec 13, 2023
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 13, 2023
@ajcvickers ajcvickers modified the milestones: Backlog, 9.0.0 Dec 13, 2023
@roji roji removed this from the 9.0.0 milestone Jan 7, 2024
ajcvickers added a commit that referenced this issue Jan 9, 2024
* Microsoft.Data.Sqlite: Cleanup when error occurs on dispose.

Fixes #25119

* Make changes as suggested by vonzshik
@ajcvickers ajcvickers added this to the 9.0.0 milestone Jan 9, 2024
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview1 Jan 31, 2024
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
@roji roji modified the milestones: 9.0.0-preview1, 9.0.0 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-adonet-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported poachable punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants