]> xenbits.xensource.com Git - people/aperard/osstest.git/commitdiff
tcl: Abolish with-db in favour of transaction
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 5 Dec 2016 15:18:57 +0000 (15:18 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 9 Dec 2016 18:41:02 +0000 (18:41 +0000)
Everything needs to be in a proper transaction, with retries.

Replace the one call site which does an ad hoc BEGIN/COMMIT with a
call to transaction.  The body here is already idempotent, so making
it be a loop body is fine.

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

index 40376601e08f2196657f3a515943ab27177bdc86..1e48e6e4da3a6e6ecbcbdc09413560e4a648b4e8 100644 (file)
@@ -266,9 +266,7 @@ proc lock-tables {tables} {
 proc spawn-step-begin {flight job ts stepnovar} {
     upvar 1 $stepnovar stepno
 
-    with-db {
-       db-execute BEGIN
-       db-execute "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"
+    transaction {} {
        if {[catch {
            lock-tables flights
            db-execute-array stepinfo "
@@ -287,7 +285,6 @@ proc spawn-step-begin {flight job ts stepnovar} {
                            [pg_quote $ts], 'running',
                            'STARTING')
            "
-           db-execute COMMIT
        } emsg]} {
            global errorInfo errorCode
            set ei $errorInfo
@@ -346,22 +343,6 @@ proc step-set-status {flight job stepno st} {
     }
 }
 
-proc with-db {script} {
-    global errorInfo errorCode
-    set rc [catch {
-       db-open
-       uplevel 1 $script
-    } result]
-    set ei $errorInfo
-    set ec $errorCode
-    if {$rc} {
-       catch { db-close }
-    } else {
-       db-close
-    }
-    return -code $rc -errorinfo $ei -errorcode $ec $result
-}
-    
 proc transaction {tables script {autoreconnect 0}} {
     global errorInfo errorCode
     variable dbopen