Skip to content

Commit

Permalink
Remove the crutch for a very unlikely concurrency possibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericDelaporte committed Feb 21, 2024
1 parent d981d26 commit 2ecb8d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/NHibernate/Transaction/AdoNetWithSystemTransactionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,12 @@ protected virtual void CompleteTransaction(bool isCommitted)
// In case of a rollback due to a timeout, we may have the session disposal running concurrently
// to the transaction completion in a way our current locking mechanism cannot fully protect: the
// session disposal "BeginProcess" can go through the Wait before it is locked but flag the
// session as procesisng after the transaction completion has read it as not processing. To dodge
// that case, we consider the session as still processing initially regardless of its actual
// status in case of rollback.
var isSessionProcessing = !isCommitted || _session.IsProcessing();
// session as processing after the transaction completion has read it as not processing. To dodge
// that very unlikely case, we could consider the session as still processing initially regardless
// of its actual status in case of rollback by changing below condition to
// "!isCommitted || _session.IsProcessing()". That would cause a Thread.Sleep in all rollback cases.
// That would reinforce the impracticality of that concurrency possibility, but with an ugly crutch.
var isSessionProcessing = _session.IsProcessing();
try
{
// Allow transaction completed actions to run while others stay blocked.
Expand Down

0 comments on commit 2ecb8d4

Please sign in to comment.