mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
add todo for corner case of transaction(&block)
This commit is contained in:
parent
751f8b26ac
commit
9bde76865e
1 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,15 @@ module DB
|
|||
begin
|
||||
yield tx
|
||||
rescue e
|
||||
# TODO check if `unless tx.closed?` should be added.
|
||||
# If it is not added, when an exception occurs after the
|
||||
# transaction is closed (explicit rollback/commit)
|
||||
# the call to rollback will trigger an exception.
|
||||
# Since the code will be in between `#transaction(&block)`
|
||||
# seems reasonable to raise an error since it might trigger
|
||||
# a design flaw. Transaction might been commited already.
|
||||
# Maybe we should wrap e in another exception that clarifies
|
||||
# this scenario.
|
||||
tx.rollback
|
||||
raise e unless e.is_a?(DB::Rollback)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue