[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 30/33] tcl daemons: transaction: Support db autoreconnect



Provide an `autoreconnect' argument which will automatically reconnect
to the db if the connection has been lost.  It will make only one
reconnection attempt.

No functional change yet because no call sites have been changed.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 tcl/JobDB-Executive.tcl | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl
index 535fbd7..0fc0a6d 100644
--- a/tcl/JobDB-Executive.tcl
+++ b/tcl/JobDB-Executive.tcl
@@ -303,7 +303,7 @@ proc step-set-status {flight job stepno st} {
     }
 }
 
-proc transaction {tables script} {
+proc transaction {tables script {autoreconnect 0}} {
     global errorInfo errorCode
     set retries 100
     while 1 {
@@ -332,6 +332,20 @@ proc transaction {tables script} {
                    after 500
                    continue
                }
+               {OSSTEST-PSQL * 08*} -
+               {OSSTEST-PSQL * 57*} -
+               {OSSTEST-PSQL-SSL-SYSCALL *} {
+                   # Class 08 — Connection Exception
+                   # Class 57 — Operator Intervention
+                   #    (includes various shutdowns)
+                   logputs stderr \
+ "db connection exception (autoreconnect=$autoreconnect): $result\n$ei\n$ec\n"
+                   if {$autoreconnect} {
+                       set autoreconnect 0; # try this only once
+                       db-reopen
+                       continue
+                   }
+               }
            }
            catch { db-ensure-closed }
        }
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.