Skip to content

Conversation

@cincuranet
Copy link
Contributor

@cincuranet cincuranet commented Aug 29, 2025

Fixes #36561.

Description

Some SQLite errors can cause automatic rollback when errors (i.e. SQLITE_FULL) occur within a transaction. The way SqliteTransaction handles this case is incorrect.

Customer impact

Using using blocks with SqliteTransaction is difficult, because different - confusing - exception is thrown, hiding the original one.

How found

Customer reported on M.D.Sqlite 9.

Regression

No.

Testing

Manual testing.

Risk

Low.

@cincuranet cincuranet requested review from artl93 and Copilot August 29, 2025 11:48
@cincuranet cincuranet requested a review from a team as a code owner August 29, 2025 11:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes improper handling of automatic rollbacks in SQLite transactions by reordering operations in the Commit() method. The issue occurs when SQLite errors (like SQLITE_FULL) cause automatic rollbacks during commit, leading to confusing exception messages when using using blocks with SqliteTransaction.

Key changes:

  • Reorder the rollback hook clearing to occur after the commit operation
  • Add explanatory comments about the timing of operations

@AndriySvyryd AndriySvyryd changed the title Properly handle automatic rollbacks in SQLite in Commit. [rc2] Properly handle automatic rollbacks in SQLite in Commit. Aug 29, 2025
Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RC2.
With this being SQLite, can we add a test for this?

@cincuranet
Copy link
Contributor Author

@artl93 Adding tests for this is not easy/reliable. One options is to reliably create race condition between multiple threads writing, which I think is a recipe for flaky test. Or for SQLITE_FULL to have no free space on disk - easy to do locally manually - but I don't see an easy way to do it on CI. :(

@cincuranet cincuranet merged commit 0acfafc into dotnet:release/10.0 Sep 1, 2025
7 checks passed
@cincuranet cincuranet deleted the autocommit-fix branch September 1, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect handling of errors that cause automatic rollbacks in SQLite

3 participants