1. Add an option to slonik to disable the version check
authorSteve Singer <steve@ssinger.info>
Mon, 21 May 2018 14:13:21 +0000 (10:13 -0400)
committerSteve Singer <steve@ssinger.info>
Wed, 1 Aug 2018 16:23:07 +0000 (12:23 -0400)
   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<ttignor@akamai.com>.

src/slon/confoptions.c
src/slon/confoptions.h
src/slon/dbutils.c
src/slon/remote_listen.c
src/slonik/slonik.c

index 56de55a7f8e21e9966ff93f19efd80f6a1125e75..4eb6b855d09cc57d6fdeb1ab221d04d8146f7031 100644 (file)
@@ -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}}
 };
 
index 75bfbfba1664765574092315cdf1bfc9b5abde79..63c5c8f4f62b9e7d1cac38963180d588c5b0f18e 100644 (file)
@@ -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;
index 8450b44b660d6d273ff26a3e2f2d886bab14f35f..f223f0c87dc607cb77226ebbfd51b700927dd1bb 100644 (file)
@@ -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
         */
index 3ba6151a53cd5d29dbf6dadaf99321247700c7d1..48a103f410a1e52f462a5293596bdea0c055f7f4 100644 (file)
@@ -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)
                                {
index 001557b9025c5f97f58eec453bac1a15bb00cc18..bd125707b6ddc6ecd32e30f2a08594a3d4d998d9 100644 (file)
@@ -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)
        {