From: Nick Wellnhofer Date: Wed, 22 Oct 2014 21:12:39 +0000 (+0200) Subject: Don't rollback when TxnScopeGuard dtor is run twice X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=13cfdad6ab07de4511cd129c7ed7c6ac58ccb4d3;p=dbsrgits%2FDBIx-Class-Historic.git Don't rollback when TxnScopeGuard dtor is run twice Modules like Plack::Middleware::StackTrace save a reference to the guard object when a (nested) rollback exception is thrown during destruction resulting in the destructor being called twice. Inactivate the guard after the first rollback. --- diff --git a/lib/DBIx/Class/Storage/TxnScopeGuard.pm b/lib/DBIx/Class/Storage/TxnScopeGuard.pm index 7cb3737..9d10265 100644 --- a/lib/DBIx/Class/Storage/TxnScopeGuard.pm +++ b/lib/DBIx/Class/Storage/TxnScopeGuard.pm @@ -106,6 +106,12 @@ sub DESTROY { } } + # Modules like Plack::Middleware::StackTrace save a reference to the + # guard object when a (nested) rollback exception is thrown resulting + # in the destructor being called twice. Inactivating the guard protects + # against trying to rollback a second time. + $self->{inactivated} = 1; + $@ = $exception; }