[open-ils-commits] r7478 - in trunk/Open-ILS/src: c-apps
perlmods/OpenILS/Application/Storage/Driver
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jun 27 16:44:27 EDT 2007
Author: miker
Date: 2007-06-27 16:41:40 -0400 (Wed, 27 Jun 2007)
New Revision: 7478
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg.pm
Log:
adding 1 second delay and retry on db connect failure -- this hack is to work around transient pgpool issues
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2007-06-27 20:31:14 UTC (rev 7477)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2007-06-27 20:41:40 UTC (rev 7478)
@@ -9,6 +9,7 @@
#include <time.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#ifdef RSTORE
# define MODULENAME "open-ils.reporter-store"
@@ -250,9 +251,12 @@
const char* err;
if (dbi_conn_connect(writehandle) < 0) {
- dbi_conn_error(writehandle, &err);
- osrfLogError( OSRF_LOG_MARK, "Error connecting to database: %s", err);
- return -1;
+ sleep(1);
+ if (dbi_conn_connect(writehandle) < 0) {
+ dbi_conn_error(writehandle, &err);
+ osrfLogError( OSRF_LOG_MARK, "Error connecting to database: %s", err);
+ return -1;
+ }
}
osrfLogInfo(OSRF_LOG_MARK, "%s successfully connected to the database", MODULENAME);
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg.pm 2007-06-27 20:31:14 UTC (rev 7477)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg.pm 2007-06-27 20:41:40 UTC (rev 7478)
@@ -71,11 +71,20 @@
"dbname=$$master{db}",
$$master{user},
$$master{pw},
- \%attrs) ||
- throw OpenSRF::EX::ERROR
- ("Couldn't connect to $$master{db}".
- " on $$master{host}::$$master{port}".
- " as $$master{user}!!");
+ \%attrs)
+ || do { sleep(1);
+ DBI->connect(
+ "dbi:Pg:".
+ "host=$$master{host};".
+ "port=$$master{port};".
+ "dbname=$$master{db}",
+ $$master{user},
+ $$master{pw},
+ \%attrs) }
+ || throw OpenSRF::EX::ERROR
+ ("Couldn't connect to $$master{db}".
+ " on $$master{host}::$$master{port}".
+ " as $$master{user}!!");
} catch Error with {
my $e = shift;
$log->debug("Error connecting to database:\n\t$e\n\t$DBI::errstr", ERROR);
@@ -87,7 +96,19 @@
$master_db->do("SET NAMES '$$master{client_encoding}';") if ($$master{client_encoding});
for my $db (@$_db_params) {
- push @slave_dbs, DBI->connect("dbi:Pg:host=$$db{host};dbname=$$db{db}",$$db{user},$$db{pw}, \%attrs);
+ try {
+ push @slave_dbs, DBI->connect("dbi:Pg:host=$$db{host};port=$$db{port};dbname=$$db{db}",$$db{user},$$db{pw}, \%attrs)
+ || do { sleep(1); DBI->connect("dbi:Pg:host=$$db{host};port=$$db{port};dbname=$$db{db}",$$db{user},$$db{pw}, \%attrs) }
+ || throw OpenSRF::EX::ERROR
+ ("Couldn't connect to $$db{db}".
+ " on $$db{host}::$$db{port}".
+ " as $$db{user}!!");
+ } catch Error with {
+ my $e = shift;
+ $log->debug("Error connecting to database:\n\t$e\n\t$DBI::errstr", ERROR);
+ throw $e;
+ };
+
$slave_dbs[-1]->do("SET NAMES '$$db{client_encoding}';") if ($$master{client_encoding});
$log->debug("Connected to MASTER db '$$master{db} at $$master{host}", INFO);
More information about the open-ils-commits
mailing list