Skip to content

Sqlite: read_uncommitted leaking outside of transaction #25101

@roji

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

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions