Skip to content

Commit

Permalink
switch tests to repeatableread
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbanister committed Jul 23, 2024
1 parent 2e3fe33 commit d0d1eba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class DatabaseTest : DatabaseTestBase
public async Task ConnectionSetup()
{
Connection = await DataSource!.OpenConnectionAsync();
Transaction = await Connection.BeginTransactionAsync(IsolationLevel.Serializable);
Transaction = await Connection.BeginTransactionAsync(IsolationLevel.RepeatableRead);
}

[TearDown]
Expand Down Expand Up @@ -235,7 +235,7 @@ Func<NpgsqlConnection, NpgsqlTransaction, Task<U>> dbOperation2
// Connection and transaction for the setup
await using var connectionForSetup = await DataSource!.OpenConnectionAsync();
await using var transactionForSetup = await connectionForSetup.BeginTransactionAsync(
IsolationLevel.Serializable
IsolationLevel.RepeatableRead
);

// Run the setup
Expand All @@ -250,7 +250,7 @@ Func<NpgsqlConnection, NpgsqlTransaction, Task<U>> dbOperation2

// Connection and transaction managed in this method for DB transaction 1
await using var connection1 = await DataSource!.OpenConnectionAsync();
await using var transaction1 = await connection1.BeginTransactionAsync(IsolationLevel.Serializable);
await using var transaction1 = await connection1.BeginTransactionAsync(IsolationLevel.RepeatableRead);

// Use these for threads to signal each other for coordination
using EventWaitHandle Transaction1Go = new AutoResetEvent(false);
Expand All @@ -271,7 +271,7 @@ Func<NpgsqlConnection, NpgsqlTransaction, Task<U>> dbOperation2

// Step #3: Create new connection and begin DB transaction 2
connection2 = await DataSource!.OpenConnectionAsync();
transaction2 = await connection2.BeginTransactionAsync(IsolationLevel.Serializable);
transaction2 = await connection2.BeginTransactionAsync(IsolationLevel.RepeatableRead);

// Step #4: Signal to transaction 1 thread to continue in parallel
Transaction1Go?.Set();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public async Task Setup()
_upsertResults.Add(await CreateUpsert().Upsert(upsertRequest, Connection!, Transaction!));

await Transaction!.CommitAsync();
Transaction = await Connection!.BeginTransactionAsync(IsolationLevel.Serializable);
Transaction = await Connection!.BeginTransactionAsync(IsolationLevel.RepeatableRead);

_deleteResult = await CreateDeleteById()
.DeleteById(
Expand Down Expand Up @@ -489,7 +489,7 @@ public async Task Setup()
_upsertResults.Add(await CreateUpsert().Upsert(upsertRequest, Connection!, Transaction!));

await Transaction!.CommitAsync();
Transaction = await Connection!.BeginTransactionAsync(IsolationLevel.Serializable);
Transaction = await Connection!.BeginTransactionAsync(IsolationLevel.RepeatableRead);

_deleteResult = await CreateDeleteById()
.DeleteById(
Expand Down Expand Up @@ -562,7 +562,7 @@ public async Task Setup()

await Transaction!.CommitAsync();

Transaction = await Connection!.BeginTransactionAsync(IsolationLevel.Serializable);
Transaction = await Connection!.BeginTransactionAsync(IsolationLevel.RepeatableRead);

_deleteResult = await CreateDeleteById()
.DeleteById(
Expand Down

0 comments on commit d0d1eba

Please sign in to comment.