From 7cf2af6f321201406eae1baf585c6bbd23745478 Mon Sep 17 00:00:00 2001 From: Steve Singer Date: Mon, 21 May 2018 10:13:21 -0400 Subject: [PATCH] 1. Add an option to slonik to disable the version check against the slony schema 2. Add an option to make the remote listener use a READ COMMITTED instead of a serialized deferrable transaction 3. If slonik was not compiled with pgport then allow PG_HOME to override/set the location of the share directory containing the slony .sql files Patches from Tom Tignor. --- src/slon/confoptions.c | 23 +++++++++++++++++++++++ src/slon/confoptions.h | 2 ++ src/slon/dbutils.c | 6 ++++++ src/slon/remote_listen.c | 29 +++++------------------------ src/slonik/slonik.c | 12 +++++++++++- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/slon/confoptions.c b/src/slon/confoptions.c index 56de55a7..4eb6b855 100644 --- a/src/slon/confoptions.c +++ b/src/slon/confoptions.c @@ -262,6 +262,29 @@ static struct config_bool ConfigureNamesBool[] = &monitor_threads, true }, + { + { + (const char *) "enable_version_check", + gettext_noop("Should services check release versions " + "and fail on differences?"), + NULL, + SLON_C_BOOL, + }, + &enable_version_check, + true + }, + { + { + (const char *) "remote_listen_serializable_transactions", + gettext_noop("Determines if the remote listener should use serializable transactions. " + "This setting trades between strict isolation and avoiding blocking " + "for lock management."), + NULL, + SLON_C_BOOL, + }, + &remote_listen_serializable_transactions, + true + }, {{0}} }; diff --git a/src/slon/confoptions.h b/src/slon/confoptions.h index 75bfbfba..63c5c8f4 100644 --- a/src/slon/confoptions.h +++ b/src/slon/confoptions.h @@ -26,6 +26,8 @@ extern int desired_sync_time; extern int quit_sync_provider; extern int quit_sync_finalsync; extern bool keep_alive; +extern bool enable_version_check; +extern bool remote_listen_serializable_transactions; extern int keep_alive_idle; extern int keep_alive_interval; extern int keep_alive_count; diff --git a/src/slon/dbutils.c b/src/slon/dbutils.c index 8450b44b..f223f0c8 100644 --- a/src/slon/dbutils.c +++ b/src/slon/dbutils.c @@ -31,6 +31,7 @@ #include "slon.h" bool keep_alive; +bool enable_version_check; int keep_alive_idle; int keep_alive_count; int keep_alive_interval; @@ -389,6 +390,11 @@ db_checkSchemaVersion(PGconn *conn) PGresult *res; int retval = 0; + if (! enable_version_check) + { + return 0; + } + /* * Select the version number from the schema */ diff --git a/src/slon/remote_listen.c b/src/slon/remote_listen.c index 3ba6151a..48a103f4 100644 --- a/src/slon/remote_listen.c +++ b/src/slon/remote_listen.c @@ -61,6 +61,7 @@ static int poll_sleep; extern char *lag_interval; int remote_listen_timeout; +bool remote_listen_serializable_transactions; static int sel_max_events = 0; @@ -295,30 +296,10 @@ remoteListenThread_main(void *cdata) } if (PQserverVersion(dbconn) >= 90100) { - slon_mkquery(&query1, "SET SESSION CHARACTERISTICS AS TRANSACTION read only deferrable"); - res = PQexec(dbconn, dstring_data(&query1)); - if (PQresultStatus(res) != PGRES_COMMAND_OK) - { - slon_log(SLON_ERROR, - "remoteListenThread_%d: \"%s\" - %s", - node->no_id, - dstring_data(&query1), PQresultErrorMessage(res)); - PQclear(res); - slon_disconnectdb(conn); - free(conn_conninfo); - conn = NULL; - conn_conninfo = NULL; - rc = sched_msleep(node, pa_connretry * 1000); - if (rc != SCHED_STATUS_OK && rc != SCHED_STATUS_CANCEL) - break; - - continue; - } - - } - if (PQserverVersion(dbconn) >= 90100) - { - slon_mkquery(&query1, "SET SESSION CHARACTERISTICS AS TRANSACTION read only isolation level serializable deferrable"); + char buf[200]; + sprintf(buf, "SET SESSION CHARACTERISTICS AS TRANSACTION read only isolation level %s", + remote_listen_serializable_transactions ? "serializable deferrable" : "repeatable read"); + slon_mkquery(&query1, buf); res = PQexec(dbconn, dstring_data(&query1)); if (PQresultStatus(res) != PGRES_COMMAND_OK) { diff --git a/src/slonik/slonik.c b/src/slonik/slonik.c index 001557b9..bd125707 100644 --- a/src/slonik/slonik.c +++ b/src/slonik/slonik.c @@ -223,8 +223,18 @@ main(int argc, const char *argv[]) get_share_path(myfull_path, share_path); } #else - strcpy(share_path, PGSHARE); + char *pgHome = getenv("PG_HOME"); + if (pgHome) + { + snprintf(share_path, MAXPGPATH-1, "%s/share", pgHome); + share_path[MAXPGPATH-1] = '\0'; + } + else + { + strcpy(share_path, PGSHARE); + } #endif +printf("Share path is %s\n",share_path); if (optind < argc) { -- 2.39.5