From: Ian Jackson Date: Tue, 15 Dec 2015 16:17:59 +0000 (+0000) Subject: Database locking: Tcl: Limit number of retries X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=af4a02e671de35e89894080b707e703d78a261bb;p=people%2Fliuw%2Fosstest.git Database locking: Tcl: Limit number of retries If there is something fundamentally wrong, don't just sit looping around every 500ms. Signed-off-by: Ian Jackson Acked-by: Ian Campbell --- diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl index 8e45ea7..7dba497 100644 --- a/tcl/JobDB-Executive.tcl +++ b/tcl/JobDB-Executive.tcl @@ -224,6 +224,8 @@ proc step-set-status {flight job stepno st} { } proc transaction {tables script} { + global errorInfo errorCode + set retries 100 db-open while 1 { set ol {} @@ -239,6 +241,10 @@ proc transaction {tables script} { } emsg]} { puts "commit failed: $emsg; retrying ..." db-execute ROLLBACK + if {[incr retries -1] <= 0} { + error \ + "commit failed, too many retries: $emsg\n$errorInfo\n$errorCode\n" + } after 500 continue }