]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
tcl daemons: transaction: Only try ROLLBACK when necessary
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 1 Jul 2016 11:23:12 +0000 (12:23 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 14 Jul 2016 12:32:49 +0000 (13:32 +0100)
In the deadlock case, we need to ROLLBACK.  In other error cases we
are going to close the connection.  And in those other cases the
ROLLBACK might fail, causing our error recovery to go wrong.

So do ROLLBACK only on the single path where we might continue to use
the connection.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tcl/JobDB-Executive.tcl

index ab6760a3216c2fbbea7c413afa960e456b868f36..45fdb189c24a5d7a443cac0e12d3e3dcaa0723fe 100644 (file)
@@ -321,10 +321,10 @@ proc transaction {tables script} {
        set ec $errorCode
        db-close
        if {$rc} {
-           db-execute ROLLBACK
            switch -glob $errorCode {
                {OSSTEST-PSQL * 40P01} {
                    # DEADLOCK DETECTED
+                   db-execute ROLLBACK
                    logputs stdout "transaction deadlock ($result) retrying ..."
                    if {[incr retries -1] <= 0} {
                        error \