diff mbox

[OSSTEST,7/9] db retry: Break out Osstest::Executive::JobDB::_need_retry

Message ID 1482259082-30767-8-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Dec. 20, 2016, 6:38 p.m. UTC
We are going to want to reorganise this.  As prep work, break the $dbh
state checking (and the corresponding comment) into a separate sub.

No functional changel.

(There is still an anomaly: need_retry passes it $dbh_tests, not the
$dbh it got from the caller.  This will go away shortly.)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index ebafb4c..5f2aac9 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -58,11 +58,11 @@  sub begin_work ($$$) { #method
     }
 }
 
-sub need_retry ($$$) {
-    my ($jd, $dbh,$committing) = @_; # implicitly, $@ is an argument too
+sub _need_retry ($) {
+    my ($dbh) = @_;
     return
-	($dbh_tests->err() // 0)==7 &&
-	($dbh_tests->state =~ m/^(?:40P01|40001|23|40002)/);
+	($dbh->err() // 0)==7 &&
+	($dbh->state =~ m/^(?:40P01|40001|23|40002)/);
     # DEADLOCK DETECTED or SERIALIZATION FAILURE
     # or any Integrity Constraint Violation including
     # TRANSACTION_INTEGRITY_CONSTRAINT_VIOLATION.
@@ -109,6 +109,11 @@  sub need_retry ($$$) {
     # https://www.postgresql.org/message-id/flat/D960CB61B694CF459DCFB4B0128514C203937E44%40exadv11.host.magwien.gv.at
 }
 
+sub need_retry ($$$) {
+    my ($jd, $dbh,$committing) = @_; # implicitly, $@ is an argument too
+    return _need_retry($dbh_tests);
+}
+
 sub readonly_report ($$) { #method
     my ($jd, $dbh) = @_;