]> xenbits.xensource.com Git - people/aperard/osstest.git/commitdiff
tcl: JobDB-Executive: Do not crash due to ROLLBACK on transaction retry
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 7 Dec 2016 13:23:52 +0000 (13:23 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 9 Dec 2016 18:41:02 +0000 (18:41 +0000)
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 <Ian.Jackson@eu.citrix.com>
tcl/JobDB-Executive.tcl

index 6eb43f6ad79c1049dddf270156e73c350f5fba9f..3f3ff29d5bfe0d121b0969f838d5fd68adbddf6f 100644 (file)
@@ -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 \