File tree 1 file changed +5
-2
lines changed
src/contrib/persistence/Akka.Persistence.Sql.Common/Journal
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -676,8 +676,11 @@ public virtual async Task<long> SelectHighestSequenceNrAsync(DbConnection connec
676
676
/// <returns>TBD</returns>
677
677
public virtual async Task InsertBatchAsync ( DbConnection connection , CancellationToken cancellationToken , WriteJournalBatch write )
678
678
{
679
- using ( var command = GetCommand ( connection , InsertEventSql ) )
680
- using ( var tx = connection . BeginTransaction ( ) )
679
+ using var command = GetCommand ( connection , InsertEventSql ) ;
680
+ // Isolation.Serializable: Enforce a table lock during the transaction when we're writing the event to database
681
+ // This is to prevent a racy condition when a high volume write is coupled with eager reading of the table
682
+ // that results in an event row missing on the read side because 2 transactions were completed out of order
683
+ using ( var tx = connection . BeginTransaction ( IsolationLevel . Serializable ) )
681
684
{
682
685
command . Transaction = tx ;
683
686
You can’t perform that action at this time.
0 commit comments