From: Ian Jackson Date: Wed, 7 Dec 2016 13:23:52 +0000 (+0000) Subject: tcl: JobDB-Executive: Do not crash due to ROLLBACK on transaction retry X-Git-Tag: openstack-v11~185 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d018b84db686c751ccd2aa833d3c0d09de68bef4;p=people%2Faperard%2Fosstest.git tcl: JobDB-Executive: Do not crash due to ROLLBACK on transaction retry If the transaction fails, we have called db-close by the time we discover it's for retry, so the dbh may be closed (depending whether we have a persistent dbh). So run ROLLBACK only if dbopen indicates that the db connection is still open. Signed-off-by: Ian Jackson --- diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl index 6eb43f6a..3f3ff29d 100644 --- a/tcl/JobDB-Executive.tcl +++ b/tcl/JobDB-Executive.tcl @@ -366,6 +366,7 @@ proc with-db {script} { proc transaction {tables script {autoreconnect 0}} { global errorInfo errorCode + variable dbopen set retries 100 while 1 { set ol {} @@ -385,7 +386,7 @@ proc transaction {tables script {autoreconnect 0}} { {OSSTEST-PSQL * 40P01} - {OSSTEST-PSQL * 40001} { # DEADLOCK DETECTED or SERIALIZATION FAILURE - db-execute ROLLBACK + if {$dbopen} { db-execute ROLLBACK } logputs stdout "transaction deadlock ($result) retrying ..." if {[incr retries -1] <= 0} { error \