Skip to content

Sqlite: read_uncommitted leaking outside of transaction #25101

Closed

Description

@roji

Executing a ReadUncommitted transaction on Sqlite sets read_uncommitted to 1, but that value seems to persist once the transaction completes.

using var conn = new SqliteConnection("Data Source=/tmp/hello.db;Cache=shared");
conn.Open();

Console.WriteLine(conn.ConnectionString);

Console.WriteLine("Before transaction: " + conn.ExecuteScalar("PRAGMA read_uncommitted"));
var tx = conn.BeginTransaction(IsolationLevel.ReadUncommitted);
Console.WriteLine("During transaction: " + conn.ExecuteScalar("PRAGMA read_uncommitted"));
tx.Commit();
Console.WriteLine("After transaction: " + conn.ExecuteScalar("PRAGMA read_uncommitted"));

Does that mean that any SQL executed after the transaction (without starting a new transaction) may see dirty reads? If so, we may want to change Commit (and Rollback?) to do something like COMMIT; PRAGMA read_uncommitted=0.

(To be fair, I'm pretty sure SqlClient has very similar issues. For comparison, in PostgreSQL you can do BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, so the level applies only to the transaction being created and doesn't leak out)

/cc @bricelam

Activity

  1. added this to the 6.0.0 milestone on Jun 15, 2021
  2. bricelam commented on Jun 15, 2021

    @bricelam
    Contributor

    🤦‍♂️

  3. bricelam commented on Jun 15, 2021

    @bricelam
    Contributor

    Note to implementor: Fix #25078 at the same time

  4. changed the title [-]read_uncommitted leaking outside of transaction[/-] [+]Sqlite: read_uncommitted leaking outside of transaction[/+] on Jul 29, 2021
  5. modified the milestones: 6.0.0, on Aug 12, 2021
  6. modified the milestones: , 6.0.0 on Nov 8, 2021
  7. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions