Fix committing or rollbacking dangling transactions#53
Conversation
👇 Click on the image for a new way to code review
Legend |
|
@tegefaulkes the exception in EFS may still occur simply because the EFS could stop the database before the committing or rollbacking has even started. In that case the dangling transaction attempts to release which will either commit or rollback. But this will cause an exception. This is unavoidable UNLESS we were to make is that committ or rollback is a noop if it is already committing or rollbacking. |
|
The |
So this change only applies to the case where I'm not sure if that will fix the EFS, or we should apply a fix in EFS to ensure that the transaction is in fact committed or rollbacked before you stop the EFS (this is the better solution). |
…en it is not already rollbacking or committing * if it is committing or rollbacking, then it should just do an early destroy, but the destroy waits for the commit or rollback to finish * if the transaction hasn't started committing or rollbacking, it may throw an exception when it does after the db is already stopped
1b8de7b to
634935f
Compare
|
Ok for now the EFS will still need to ensure that they are in fact committing or rollbacking any dangling transactions. But the |

Description
In the EFS, we came across a problem where there is a dangling transaction that is still pending. It may be neither committed, nor rollbacked, or it may be in the process of committing or rollbacking.
Either way, when the
DB.stop()is called, it proceeds to rollback all existing transactions in the transaction reference set.Ideally, all transactions should be committed or rollbacked before the
await db.stop()is called. However if there are dangling transactions there should be rollbacked if their status is neither committed or rollbacked, but if they have a particular status, then theDB.stopshould be waiting for those pending statuses to finish.Here we introduce a lock to be used between
DBTransaction.destroy,DBTransaction.commitandDBTransaction.rollback. The basic idea is fordestroyto wait on a commit or rollback to finish. This allows one to callawait transaction.destroy()while the committing or rollbacking is occurring.However at the same time, if a transaction is pending to commit, but hasn't started committing. It's possible for the
DB.stop()to already start rollbacking. If this occurs, during the resource release, the transaction will attempt to commit, in that case, an exception still occurs because the transaction is already rollbacked. This is a legitimate exception.Issues Fixed
Tasks
DB.stop()only performsawait transaction.rollbackwhen the transaction is neither committing nor rollbacking. If it is in the middle of comitting or rollbacking then it should just wait for it complete.tests/DBTransaction.test.tsawait this.destroy()fromDBTransaction.commitandDBTransaction.rollback, this is done automatically be the resource releaseFinal checklist