@@ -283,25 +283,27 @@ proc transaction {tables script} {
db-execute "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"
lock-tables $tables
uplevel 1 $script
+ db-execute COMMIT
} result]
- if {!$rc} {
- if {[catch {
- db-execute COMMIT
- } 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"
+ set ei $errorInfo
+ set ec $errorCode
+ if {$rc} {
+ db-execute ROLLBACK
+ switch -glob $errorCode {
+ {OSSTEST-PSQL * 40P01} {
+ # DEADLOCK DETECTED
+ puts "transaction deadlock ($result) retrying ..."
+ if {[incr retries -1] <= 0} {
+ error \
+ "transaction failed, too many retries: $result\n$errorInfo\n$errorCode\n"
+ }
+ after 500
+ continue
}
- after 500
- continue
}
- } else {
- db-execute ROLLBACK
}
db-close
- return -code $rc $result
+ return -code $rc -errorinfo $ei -errorcode $ec $result
}
}