Fist cut patch to deal with logical replication.
authorTatsuo Ishii <ishii@postgresql.org>
Thu, 17 Aug 2017 07:10:24 +0000 (16:10 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Thu, 17 Aug 2017 07:10:24 +0000 (16:10 +0900)
24 files changed:
doc.ja/src/sgml/connection-settings.sgml
doc.ja/src/sgml/runtime.sgml
doc/src/sgml/connection-settings.sgml
doc/src/sgml/runtime.sgml
src/Makefile.am
src/Makefile.in
src/config/pool_config_variables.c
src/context/pool_query_context.c
src/context/pool_session_context.c
src/include/pool.h
src/include/pool_config.h
src/main/pgpool_main.c
src/protocol/CommandComplete.c
src/protocol/child.c
src/protocol/pool_connection_pool.c
src/protocol/pool_process_query.c
src/protocol/pool_proto_modules.c
src/query_cache/pool_memqcache.c
src/sample/pgpool.conf.sample
src/sample/pgpool.conf.sample-logical [new file with mode: 0644]
src/sample/pgpool.conf.sample-master-slave
src/sample/pgpool.conf.sample-replication
src/sample/pgpool.conf.sample-stream
src/test/pgpool_setup

index 25066adce43f90b55084a93d69cde54d7c48d7a8..81a219874a31e51278b88fca7fc7fe957d99d891 100644 (file)
@@ -435,7 +435,7 @@ md5 認証で用いるパスワードのファイルのファイル名を指定
        </sect2>
 </sect1>
 
-<sect1 id="runtime-config-runnung-mode">
+<sect1 id="runtime-config-running-mode">
 <!--
        <title>Running mode</title>
 -->
@@ -577,6 +577,14 @@ md5 認証で用いるパスワードのファイルのファイル名を指定
                                                                        <entry><productname>PostgreSQL</>の組み込みレプリケーションシステム(ストリーミングレプリケーション)に適合</entry>
                                                                </row>
 
+                                                               <row>
+                                                                       <entry><literal>'logical'</literal></entry>
+<!--
+                                                                       <entry>Suitable for <productname>PostgreSQL</>'s built-in replication system (Logical Replication)</entry>
+-->
+                                                                       <entry><productname>PostgreSQL</>の組み込みレプリケーションシステム(ロジカルレプリケーション)に適合</entry>
+                                                               </row>
+
                                                        </tbody>
                                                </tgroup>
                                        </table>
index 5fbbf52ecd29eb30c1b9ee8eae1ef2153cb74862..71c2cf8e0ec359e2053ee0bea9e69e963042bdb5 100644 (file)
@@ -225,6 +225,24 @@ password: <userinput>your_password</userinput>
 サンプルの設定ファイルは<filename>$prefix/etc/pgpool.conf.sample-stream</filename>です。
     </para>
 
+    <para>
+  <!--
+      The logical replication mode can be used
+      with <productname>PostgreSQL</> servers operating logical
+      replication. In this mode, <productname>PostgreSQL</> is
+      responsible for synchronizing tables. Load balancing is possible
+      in the mode. Since logical replication does not replicate all
+      tables, it's user's responsibility to replicate the table which
+      could be load balanced.  The sample configuration file
+      is <filename>$prefix/etc/pgpool.conf.sample-logical</filename>.
+-->
+ロジカルレプリケーションモードはロジカルレプリケーションを使用する<productname>PostgreSQL</>サーバと一緒に使うことができます。
+このモードでは、<productname>PostgreSQL</>がテーブルを同期する責任を持ちます。
+このモードでは負荷分散が可能です。
+ロジカルレプリケーションは必ずしもすべてのテーブルをレプリケーションしないので、負荷分散させるテーブルがレプリケーションされるようにするのはユーザの責任です。
+サンプルの設定ファイルは<filename>$prefix/etc/pgpool.conf.sample-logical</filename>です。
+    </para>
+
     <para>
 <!--
       The master slave mode mode can be used with <productname>PostgreSQL</> servers
index 89e4934754958aa571be91a3c21d621dbf2eee78..b595429a1ce572c9770d2f1d7d82ff98fd40d147 100644 (file)
   </sect2>
 </sect1>
 
-<sect1 id="runtime-config-runnung-mode">
+<sect1 id="runtime-config-running-mode">
   <title>Running mode</title>
 
   <sect2 id="runtime-config-master-slave-mode">
                    replication system (Streaming Replication)</entry>
                </row>
 
+               <row>
+                 <entry><literal>'logical'</literal></entry>
+                 <entry>Suitable
+                   for <productname>PostgreSQL</productname>'s built-in
+                   replication system (Logical Replication)</entry>
+               </row>
+
              </tbody>
            </tgroup>
          </table>
index 16f9afe10abc71fe846a09fa2d72617d69fd7b0e..c40f58ae23eaf7c588123604ef05ec9d2af493c4 100644 (file)
@@ -149,6 +149,17 @@ password: <userinput>your_password</userinput>
       is <filename>$prefix/etc/pgpool.conf.sample-stream</filename>.
     </para>
 
+    <para>
+      The logical replication mode can be used
+      with <productname>PostgreSQL</> servers operating logical
+      replication. In this mode, <productname>PostgreSQL</> is
+      responsible for synchronizing tables. Load balancing is possible
+      in the mode. Since logical replication does not replicate all
+      tables, it's user's responsibility to replicate the table which
+      could be load balanced.  The sample configuration file
+      is <filename>$prefix/etc/pgpool.conf.sample-logical</filename>.
+    </para>
+
     <para>
       The master slave mode mode can be used with <productname>PostgreSQL</> servers
       operating <productname>Slony</>. In this mode, <productname>Slony</>/<productname>PostgreSQL</> is responsible for
index 2d3edb8e2a90457bbaac3608ac942597b9ee4155..f9a8db3e68958c5bf123d1f98e6c214f0894b49b 100644 (file)
@@ -62,7 +62,8 @@ sysconf_DATA = sample/pgpool.conf.sample \
                           sample/pool_hba.conf.sample \
                           sample/pgpool.conf.sample-replication \
                           sample/pgpool.conf.sample-master-slave \
-                          sample/pgpool.conf.sample-stream
+                          sample/pgpool.conf.sample-stream \
+                          sample/pgpool.conf.sample-logical
 
 pkgdata_DATA = sql/insert_lock.sql \
                           sample/pgpool.pam
index bb2b894e24ddff23adbb709ff327c50e1523c202..fac5404c303c2460750bdd77fea69d740acb4529 100644 (file)
@@ -496,7 +496,8 @@ sysconf_DATA = sample/pgpool.conf.sample \
                           sample/pool_hba.conf.sample \
                           sample/pgpool.conf.sample-replication \
                           sample/pgpool.conf.sample-master-slave \
-                          sample/pgpool.conf.sample-stream
+                          sample/pgpool.conf.sample-stream \
+                          sample/pgpool.conf.sample-logical
 
 pkgdata_DATA = sql/insert_lock.sql \
                           sample/pgpool.pam
index 85d7eab25a25dffb24f29376eb92773342bde8e2..f44ef4120c746d99ca7175c3c00726cbc1406661 100644 (file)
@@ -180,6 +180,7 @@ static const struct config_enum_entry server_message_level_options[] = {
 static const struct config_enum_entry master_slave_sub_mode_options[] = {
        {"slony", SLONY_MODE, false},
        {"stream", STREAM_MODE, false},
+       {"logical", LOGICAL_MODE, false},
        {NULL, 0, false}
 };
 
@@ -1752,7 +1753,7 @@ static struct config_enum ConfigureNamesEnum[] =
                        CONFIG_VAR_TYPE_ENUM,false, 0
                },
                (int*)&g_pool_config.master_slave_sub_mode,
-               SLONY_MODE,
+               STREAM_MODE,
                master_slave_sub_mode_options,
                NULL, NULL, NULL, NULL
        },
index b0e7edaa8cf1282fc2937fbb4001ef8a5ce39c45..877164fcbecde4461ea518e596e9e03670c0bfbb 100644 (file)
@@ -217,8 +217,7 @@ void pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT *query_context)
                         * primary node nor load balance node, there's no point to
                         * send query.
                         */
-                       if (pool_config->master_slave_mode &&
-                               pool_config->master_slave_sub_mode == STREAM_MODE &&
+                       if (SL_MODE &&
                                i != PRIMARY_NODE_ID && i != sc->load_balance_node_id)
                        {
                                continue;
@@ -309,7 +308,7 @@ int pool_virtual_master_db_node_id(void)
        {
                int node_id = sc->query_context->virtual_master_node_id;
 
-               if (STREAM)
+               if (SL_MODE)
                {
                         /*
                          * Make sure that virtual_master_node_id is either primary node
@@ -502,7 +501,7 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no
                                        /*
                                         * If replication delay is too much, we prefer to send to the primary.
                                         */
-                                       if (pool_config->master_slave_sub_mode == STREAM_MODE &&
+                                       if (STREAM &&
                                                pool_config->delay_threshold &&
                                                bkinfo->standby_delay > pool_config->delay_threshold)
                                        {
index 2e93985a681886b86245f2b08472577706228612..f0afe12e8e5b45528d9c91328601e3bd1a606d42 100644 (file)
@@ -98,7 +98,7 @@ void pool_init_session_context(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *
        }
        else
        {
-               node_id = STREAM? PRIMARY_NODE_ID: MASTER_NODE_ID;
+               node_id = SL_MODE? PRIMARY_NODE_ID: MASTER_NODE_ID;
        }
 
        session_context->load_balance_node_id = node_id;
index ac282ba72be1dfae433a54a78c56b92ab022c71a..b2f10ca6ff83575795de5d473bec9008263d9a2d 100644 (file)
@@ -350,9 +350,11 @@ extern int my_master_node_id;
 #define REPLICATION (pool_config->replication_mode)
 #define MASTER_SLAVE (pool_config->master_slave_mode)
 #define STREAM (MASTER_SLAVE && pool_config->master_slave_sub_mode == STREAM_MODE)
+#define LOGICAL (MASTER_SLAVE && pool_config->master_slave_sub_mode == LOGICAL_MODE)
 #define SLONY (MASTER_SLAVE && pool_config->master_slave_sub_mode == SLONY_MODE)
 #define DUAL_MODE (REPLICATION || MASTER_SLAVE)
 #define RAW_MODE (!REPLICATION && !MASTER_SLAVE)
+#define SL_MODE (STREAM || LOGICAL)    /* streaming or logical replication mode */
 #define MAJOR(p) (pool_get_major_version())
 #define TSTATE(p, i) (CONNECTION(p, i)->tstate)
 #define INTERNAL_TRANSACTION_STARTED(p, i) (CONNECTION(p, i)->is_internal_transaction_started)
index 3d0052f017687452320632642fdb5e41de4a640c..aeb630828793a4fe8e5c5050fdc9219105214e13 100644 (file)
@@ -56,7 +56,8 @@ typedef struct {
 typedef enum MasterSlaveSubModes
 {
        SLONY_MODE = 1,
-       STREAM_MODE
+       STREAM_MODE,
+       LOGICAL_MODE
 }MasterSlaveSubModes;
 
 typedef enum LogStandbyDelayModes
index f029be4ab6708540453675d6a7f8e6c7ef4100be..8b45c9e290a6bb3c06a9b6b26d296830b8124c5c 100644 (file)
@@ -1103,7 +1103,7 @@ bool promote_backend(int node_id, unsigned int wd_failover_id)
        WDFailoverCMDResults res = FAILOVER_RES_PROCEED;
        bool ret = false;
 
-       if (!MASTER_SLAVE || pool_config->master_slave_sub_mode != STREAM_MODE)
+       if (!SL_MODE)
        {
                return false;
        }
@@ -1812,7 +1812,7 @@ static void failover(void)
                 * recognize the former primary as the new primary node, which
                 * will reduce the time to process standby down.
                 */
-               else if (MASTER_SLAVE && pool_config->master_slave_sub_mode == STREAM_MODE &&
+               else if (SL_MODE &&
                                 reqkind == NODE_DOWN_REQUEST)
                {
                        if (Req_info->primary_node_id != node_id)
@@ -1829,7 +1829,7 @@ static void failover(void)
                 * as they are not replicated anymore.
                 */
                int follow_cnt = 0;
-               if (MASTER_SLAVE && pool_config->master_slave_sub_mode == STREAM_MODE)
+               if (STREAM)
                {
                        if (*pool_config->follow_master_command != '\0' ||
                                reqkind == PROMOTE_NODE_REQUEST)
@@ -2811,7 +2811,7 @@ static int find_primary_node(void)
        int i;
 
        /* Streaming replication mode? */
-       if (!STREAM)
+       if (!SL_MODE)
        {
                /* No point to look for primary node if not in streaming
                 * replication mode.
@@ -2881,8 +2881,7 @@ static int find_primary_node_repeatedly(void)
        int node_id = -1;
 
        /* Streaming replication mode? */
-       if (pool_config->master_slave_mode == false ||
-               pool_config->master_slave_sub_mode != STREAM_MODE)
+       if (!SL_MODE)
        {
                /* No point to look for primary node if not in streaming
                 * replication mode.
index acba4e25fc8bbfed7499dc6adbe53101f4c8588b..3b5fc3a21d1c5b3aba734598a8746ba394232e28 100644 (file)
@@ -62,7 +62,7 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
        /*
         * Handle misc process which is neccessary when query context exists.
         */
-       if (session_context->query_context != NULL && !STREAM)
+       if (session_context->query_context != NULL && !SL_MODE)
                handle_query_context(backend);
 
        /*
@@ -70,7 +70,7 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
         * read backend message according to the query context.
         * Also we set the transaction state at this point.
         */
-       if (STREAM && pool_is_doing_extended_query_message())
+       if (SL_MODE && pool_is_doing_extended_query_message())
        {
                for (i=0;i<NUM_BACKENDS;i++)
                {
@@ -130,7 +130,7 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
         * do mismatch tuples process (forwarding to frontend is done in
         * handle_mismatch_tuples().
         */
-       if (STREAM && pool_is_doing_extended_query_message())
+       if (SL_MODE && pool_is_doing_extended_query_message())
        {
                int status;
 
@@ -160,7 +160,7 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
                 * If we are in streaming replication mode and we are doing extended
                 * query, register query cache now.
                 */
-               if (STREAM && pool_is_doing_extended_query_message())
+               if (SL_MODE && pool_is_doing_extended_query_message())
                {
                        char *query;
                        Node *node;
@@ -184,7 +184,7 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
         * If we are in streaming replication mode and we are doing extended
         * query, reset query in progress flag and prevoius pending message.
        */
-       if (STREAM && pool_is_doing_extended_query_message())
+       if (SL_MODE && pool_is_doing_extended_query_message())
        {
                pool_at_command_success(frontend, backend);
                pool_unset_query_in_progress();
index 859e0befa8b40e165847865a72961cf7c4453fcb..2e761d5c391fbab4b7239399363a293e2b67695b 100644 (file)
@@ -1673,7 +1673,7 @@ int select_load_balancing_node(void)
        /* 
         * Check database_redirect_preference_list
         */
-       if (STREAM && pool_config->redirect_dbnames)
+       if (SL_MODE && pool_config->redirect_dbnames)
        {
                char *database = MASTER_CONNECTION(ses->backend)->sp->database;
 
@@ -1699,7 +1699,7 @@ int select_load_balancing_node(void)
        /* 
         * Check app_name_redirect_preference_list
         */
-       if (STREAM && pool_config->redirect_app_names)
+       if (SL_MODE && pool_config->redirect_app_names)
        {
                char *app_name = MASTER_CONNECTION(ses->backend)->sp->application_name;
 
index d4667788ae5a04b08f6f1fab4172b2913208f60b..2bbcae24c500adfa443a21e1e49a0a81dfb6152f 100644 (file)
@@ -865,7 +865,7 @@ static POOL_CONNECTION_POOL *new_connection(POOL_CONNECTION_POOL *p)
                                 * If we are in streaming replication mode and the node is a
                                 * standby node, then we skip this node to avoid fail over.
                                 */
-                               if (STREAM && !IS_PRIMARY_NODE_ID(i))
+                               if (SL_MODE && !IS_PRIMARY_NODE_ID(i))
                                {
                                        ereport(LOG,
                                                        (errmsg("failed to create a backend %d connection", i),
index 5eec4a54874937ce938fcb791ee409615dcdc852..9631a5fb8c331aefd489df946e231f4a9ec5b3b7 100644 (file)
@@ -366,12 +366,12 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
                                                                                        pool_unread(CONNECTION(backend, MASTER_NODE_ID), &kind, sizeof(kind));
                                                                                }
                                                                        }
-                                                                       else if (STREAM)
+                                                                       else if (SL_MODE)
                                                                        {
                                                                                pool_unread(CONNECTION(backend, i), &kind, sizeof(kind));
                                                                        }
 
-                                                                       else if (!STREAM)
+                                                                       else if (!SL_MODE)
                                                                        {
                                         ereport(LOG,
                                                 (errmsg("pool process query"),
@@ -567,7 +567,7 @@ POOL_STATUS send_extended_protocol_message(POOL_CONNECTION_POOL *backend,
        pool_write(cp, &sendlen, sizeof(sendlen));
        pool_write(cp, string, len);
 
-       if (!STREAM)
+       if (!SL_MODE)
        {
                /*
                 * send "Flush" message so that backend notices us
@@ -1899,7 +1899,7 @@ void do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result
                 * backend. The saved packets will be poped up before returning to
                 * caller. This preserves the user's expectation of packet sequence.
                 */
-               if (STREAM && pool_pending_message_exists())
+               if (SL_MODE && pool_pending_message_exists())
                {
                        data_pushed = pool_push_pending_data(backend);
                }
@@ -3133,7 +3133,7 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
 
        memset(kind_map, 0, sizeof(kind_map));
 
-       if (STREAM && pool_get_session_context(true) && pool_is_doing_extended_query_message())
+       if (SL_MODE && pool_get_session_context(true) && pool_is_doing_extended_query_message())
        {
                msg = pool_pending_message_head_message();
                previous_message = pool_pending_message_get_previous_message();
@@ -3399,7 +3399,7 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
                if (session_context->load_balance_node_id != MASTER_NODE_ID &&
                        (kind_list[MASTER_NODE_ID] == 'Z' ||
                         kind_list[session_context->load_balance_node_id] == 'Z')
-                       && STREAM)
+                       && SL_MODE)
                {
                        POOL_CONNECTION *s;
                        char *buf;
@@ -3617,7 +3617,7 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
         * 'describe', the message must not be pulled out so that the row
         * description message from backend matches the describe message.
         */
-       if (STREAM && pool_is_doing_extended_query_message() && msg)
+       if (SL_MODE && pool_is_doing_extended_query_message() && msg)
        {
                if ((msg->type == POOL_EXECUTE &&
                         (*decided_kind == 'D' || *decided_kind == 'E' || *decided_kind == 'N')) ||
@@ -4657,7 +4657,7 @@ pool_config->client_idle_limit)));
                                         * If shutdown node is not primary nor load balance node,
                                         * we do not need to trigger failover.
                                         */
-                                       if (STREAM &&
+                                       if (SL_MODE &&
                                                (i == PRIMARY_NODE_ID || i == backend->info->load_balancing_node))
                                        {
                                                /* detach backend node. */
index 764acceefc23950b2b040c2aa0168930f5447589..191668324a41de7b6ccda8507cc29d449d243a21 100644 (file)
@@ -522,7 +522,7 @@ POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend,
                 * - statement is INSERT
                 * - either "INSERT LOCK" comment exists or insert_lock directive specified
                 */
-               if (!RAW_MODE && !STREAM)
+               if (!RAW_MODE && !SL_MODE)
                {
                        /*
                         * If there's only one node to send the command, there's no
@@ -831,7 +831,7 @@ POOL_STATUS Execute(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
                        stop_now = true;
 #endif
                        
-                       if (!STREAM || !pool_is_doing_extended_query_message())
+                       if (!SL_MODE || !pool_is_doing_extended_query_message())
                        {
                                pool_set_skip_reading_from_backends();
                                pool_stats_count_up_num_cache_hits();
@@ -854,7 +854,7 @@ POOL_STATUS Execute(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
        /* check if query is "COMMIT" or "ROLLBACK" */
        commit = is_commit_or_rollback_query(node);
 
-       if (!STREAM)
+       if (!SL_MODE)
        {
                /*
                 * Query is not commit/rollback
@@ -1256,7 +1256,7 @@ POOL_STATUS Parse(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
                        pool_extended_send_and_wait(query_context, "P", len, contents, -1, MASTER_NODE_ID, false);
                }
        }
-       else if (STREAM)
+       else if (SL_MODE)
        {
                POOL_PENDING_MESSAGE *pmsg;
 
@@ -1357,7 +1357,7 @@ POOL_STATUS Bind(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
        if (pool_config->load_balance_mode && pool_is_writing_transaction() &&
                TSTATE(backend, MASTER_SLAVE ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) == 'T')
        {
-               if (!STREAM)
+               if (!SL_MODE)
                {
                        pool_where_to_send(query_context, query_context->original_query,
                                                           query_context->parse_tree);
@@ -1403,7 +1403,7 @@ POOL_STATUS Bind(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
 
        pool_set_query_in_progress();
 
-       if (STREAM)
+       if (SL_MODE)
        {
                nowait = true;
                session_context->query_context = query_context = bind_msg->query_context;
@@ -1414,7 +1414,7 @@ POOL_STATUS Bind(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
        pool_extended_send_and_wait(query_context, "B", len, contents, 1, MASTER_NODE_ID, nowait);
        pool_extended_send_and_wait(query_context, "B", len, contents, -1, MASTER_NODE_ID, nowait);
 
-       if (STREAM)
+       if (SL_MODE)
        {
                POOL_PENDING_MESSAGE *pmsg;
 
@@ -1488,13 +1488,13 @@ POOL_STATUS Describe(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
     ereport(DEBUG1,
             (errmsg("Describe: waiting for master completing the query")));
 
-       nowait = (STREAM? true: false);
+       nowait = (SL_MODE? true: false);
 
        pool_set_query_in_progress();
        pool_extended_send_and_wait(query_context, "D", len, contents, 1, MASTER_NODE_ID, nowait);
        pool_extended_send_and_wait(query_context, "D", len, contents, -1, MASTER_NODE_ID, nowait);
 
-       if (STREAM)
+       if (SL_MODE)
        {
                POOL_PENDING_MESSAGE *pmsg;
 
@@ -1573,7 +1573,7 @@ POOL_STATUS Close(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
 
        pool_set_query_in_progress();
 
-       if (!STREAM)
+       if (!SL_MODE)
        {
                pool_extended_send_and_wait(query_context, "C", len, contents, 1, MASTER_NODE_ID, false);
                pool_extended_send_and_wait(query_context, "C", len, contents, -1, MASTER_NODE_ID, false);
@@ -1970,7 +1970,7 @@ POOL_STATUS ParseComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backe
        /* Get session context */
        session_context = pool_get_session_context(false);
 
-       if (!STREAM && session_context->uncompleted_message)
+       if (!SL_MODE && session_context->uncompleted_message)
        {
                POOL_QUERY_CONTEXT *qc;
 
@@ -1993,7 +1993,7 @@ POOL_STATUS BindComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backen
        /* Get session context */
        session_context = pool_get_session_context(false);
 
-       if (!STREAM && session_context->uncompleted_message)
+       if (!SL_MODE && session_context->uncompleted_message)
        {
                POOL_QUERY_CONTEXT *qc;
 
@@ -2023,7 +2023,7 @@ POOL_STATUS CloseComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backe
        status = SimpleForwardToFrontend('3', frontend, backend);
 
        /* Remove the target message */
-       if (STREAM)
+       if (SL_MODE)
        {
                POOL_PENDING_MESSAGE *pmsg;
 
@@ -2165,7 +2165,7 @@ POOL_STATUS ErrorResponse3(POOL_CONNECTION *frontend,
        if (ret != POOL_CONTINUE)
                return ret;
 
-       if (!STREAM)
+       if (!SL_MODE)
                raise_intentional_error_if_need(backend);
 
        return POOL_CONTINUE;
@@ -2404,7 +2404,7 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend,
                        if (pool_is_ignore_till_sync())
                                pool_unset_ignore_till_sync();
 
-                       if (STREAM)
+                       if (SL_MODE)
                        {
                                POOL_PENDING_MESSAGE *msg;
 
@@ -2417,7 +2417,7 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend,
                                pool_set_query_in_progress();
                        status = SimpleForwardToBackend(fkind, frontend, backend, len, contents);
 
-                       if (STREAM)
+                       if (SL_MODE)
                        {
                                /* Wait till Ready for query received */
                                pool_wait_till_ready_for_query(backend);
@@ -2560,7 +2560,7 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
                                break;
 
                        case '1':       /* ParseComplete */
-                               if (STREAM)
+                               if (SL_MODE)
                                {
                                        POOL_PENDING_MESSAGE *pmsg;
                                        pmsg = pool_pending_message_get_previous_message();
@@ -2580,19 +2580,19 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
                                }
                                status = ParseComplete(frontend, backend);
                                pool_set_command_success();
-                               if (STREAM||REPLICATION||RAW_MODE)
+                               if (SL_MODE||REPLICATION||RAW_MODE)
                                        pool_unset_query_in_progress();
                                break;
 
                        case '2':       /* BindComplete */
                                status = BindComplete(frontend, backend);
                                pool_set_command_success();
-                               if (STREAM||REPLICATION||RAW_MODE)
+                               if (SL_MODE||REPLICATION||RAW_MODE)
                                        pool_unset_query_in_progress();
                                break;
 
                        case '3':       /* CloseComplete */
-                               if (STREAM)
+                               if (SL_MODE)
                                {
                                        POOL_PENDING_MESSAGE *pmsg;
                                        pmsg = pool_pending_message_get_previous_message();
@@ -2613,7 +2613,7 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
 
                                status = CloseComplete(frontend, backend);
                                pool_set_command_success();
-                               if (STREAM||REPLICATION||RAW_MODE)
+                               if (SL_MODE||REPLICATION||RAW_MODE)
                                        pool_unset_query_in_progress();
                                break;
 
@@ -2627,7 +2627,7 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
                                {
                                        pool_set_ignore_till_sync();
                                        pool_unset_query_in_progress();
-                                       if (STREAM)
+                                       if (SL_MODE)
                                                pool_discard_except_sync_and_ready_for_query(frontend, backend);
                                }
                                break;
@@ -2677,10 +2677,6 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
                                status = SimpleForwardToFrontend(kind, frontend, backend);
                                break;
                }
-#ifdef NOT_USED
-               if (STREAM && pool_is_doing_extended_query_message())
-                       pool_reset_preferred_master_node_id();
-#endif
        }
        else
        {
@@ -3159,7 +3155,7 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION *frontend,
 
        memcpy(backup, qc->where_to_send, sizeof(qc->where_to_send));
 
-       if (STREAM)
+       if (SL_MODE)
        {
                if (message->kind == 'P' && qc->where_to_send[PRIMARY_NODE_ID] == 0)
                {
@@ -3264,7 +3260,7 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION *frontend,
                }
        }
        
-       if (!STREAM && parse_was_sent)
+       if (!SL_MODE && parse_was_sent)
        {
                while (kind != '1')
                {
@@ -3527,7 +3523,7 @@ static void pool_discard_except_sync_and_ready_for_query(POOL_CONNECTION *fronte
        POOL_PENDING_MESSAGE *pmsg;
        int i;
 
-       if (!pool_is_doing_extended_query_message() || !STREAM)
+       if (!pool_is_doing_extended_query_message() || !SL_MODE)
                return;
 
        /*
index 905710aad91711049989bfa19ab291af78a888e2..f2d35e3d7b0e79725f53719e98750d94cbeeab2b 100644 (file)
@@ -644,7 +644,7 @@ POOL_STATUS pool_fetch_from_memory_cache(POOL_CONNECTION *frontend,
         * replication mode, we need to retrieve any responses from backend and
         * forward them to frontend.
         */
-       if (pool_is_doing_extended_query_message() && STREAM)
+       if (pool_is_doing_extended_query_message() && SL_MODE)
        {
                POOL_SESSION_CONTEXT *session_context;
                POOL_CONNECTION *target_backend;
@@ -680,7 +680,7 @@ POOL_STATUS pool_fetch_from_memory_cache(POOL_CONNECTION *frontend,
                send_message(frontend, 'Z', 5, (char *)&state);
        }
 
-       if (!pool_is_doing_extended_query_message() || !STREAM)
+       if (!pool_is_doing_extended_query_message() || !SL_MODE)
        {
                if (pool_flush(frontend))
                {
@@ -3163,7 +3163,7 @@ void pool_handle_query_cache(POOL_CONNECTION_POOL *backend, char *query, Node *n
                                                        (errmsg("pool_handle_query_cache: temp_cache: %p", cache)));
                                        pool_discard_temp_query_cache(cache);
 
-                                       if (STREAM && pool_is_doing_extended_query_message())
+                                       if (SL_MODE && pool_is_doing_extended_query_message())
                                                session_context->query_context->temp_cache = NULL;
                                        else
                                                session_context->query_context->temp_cache = pool_create_temp_query_cache(query);
index b0350e3c0ff198d0de4680c7e627f56301cf32a1..5c5c360d05311619b9b73a21326e396a103442a9 100644 (file)
@@ -320,8 +320,8 @@ master_slave_mode = off
                                    # (change requires restart)
 master_slave_sub_mode = 'slony'
                                    # Master/slave sub mode
-                                   # Valid values are combinations slony or
-                                   # stream. Default is slony.
+                                   # Valid values are combinations stream, slony
+                                   # or logical. Default is stream.
                                    # (change requires restart)
 
 # - Streaming -
diff --git a/src/sample/pgpool.conf.sample-logical b/src/sample/pgpool.conf.sample-logical
new file mode 100644 (file)
index 0000000..8e8fa39
--- /dev/null
@@ -0,0 +1,732 @@
+# ----------------------------
+# pgPool-II configuration file
+# ----------------------------
+#
+# This file consists of lines of the form:
+#
+#   name = value
+#
+# Whitespace may be used.  Comments are introduced with "#" anywhere on a line.
+# The complete list of parameter names and allowed values can be found in the
+# pgPool-II documentation.
+#
+# This file is read on server startup and when the server receives a SIGHUP
+# signal.  If you edit the file on a running system, you have to SIGHUP the
+# server for the changes to take effect, or use "pgpool reload".  Some
+# parameters, which are marked below, require a server shutdown and restart to
+# take effect.
+#
+
+
+#------------------------------------------------------------------------------
+# CONNECTIONS
+#------------------------------------------------------------------------------
+
+# - pgpool Connection Settings -
+
+listen_addresses = 'localhost'
+                                   # Host name or IP address to listen on:
+                                   # '*' for all, '' for no TCP/IP connections
+                                   # (change requires restart)
+port = 9999
+                                   # Port number
+                                   # (change requires restart)
+socket_dir = '/tmp'
+                                   # Unix domain socket path
+                                   # The Debian package defaults to
+                                   # /var/run/postgresql
+                                   # (change requires restart)
+
+
+# - pgpool Communication Manager Connection Settings -
+
+pcp_listen_addresses = '*'
+                                   # Host name or IP address for pcp process to listen on:
+                                   # '*' for all, '' for no TCP/IP connections
+                                   # (change requires restart)
+pcp_port = 9898
+                                   # Port number for pcp
+                                   # (change requires restart)
+pcp_socket_dir = '/tmp'
+                                   # Unix domain socket path for pcp
+                                   # The Debian package defaults to
+                                   # /var/run/postgresql
+                                   # (change requires restart)
+listen_backlog_multiplier = 2
+                                   # Set the backlog parameter of listen(2) to
+                                                                  # num_init_children * listen_backlog_multiplier.
+                                   # (change requires restart)
+serialize_accept = off
+                                   # whether to serialize accept() call to avoid thundering herd problem
+                                   # (change requires restart)
+
+# - Backend Connection Settings -
+
+backend_hostname0 = 'host1'
+                                   # Host name or IP address to connect to for backend 0
+backend_port0 = 5432
+                                   # Port number for backend 0
+backend_weight0 = 1
+                                   # Weight for backend 0 (only in load balancing mode)
+backend_data_directory0 = '/data'
+                                   # Data directory for backend 0
+backend_flag0 = 'ALLOW_TO_FAILOVER'
+                                   # Controls various backend behavior
+                                   # ALLOW_TO_FAILOVER, DISALLOW_TO_FAILOVER
+                                  # or ALWAYS_MASTER
+#backend_hostname1 = 'host2'
+#backend_port1 = 5433
+#backend_weight1 = 1
+#backend_data_directory1 = '/data1'
+#backend_flag1 = 'ALLOW_TO_FAILOVER'
+
+# - Authentication -
+
+enable_pool_hba = off
+                                   # Use pool_hba.conf for client authentication
+pool_passwd = 'pool_passwd'
+                                   # File name of pool_passwd for md5 authentication.
+                                   # "" disables pool_passwd.
+                                   # (change requires restart)
+authentication_timeout = 60
+                                   # Delay in seconds to complete client authentication
+                                   # 0 means no timeout.
+
+# - SSL Connections -
+
+ssl = off
+                                   # Enable SSL support
+                                   # (change requires restart)
+#ssl_key = './server.key'
+                                   # Path to the SSL private key file
+                                   # (change requires restart)
+#ssl_cert = './server.cert'
+                                   # Path to the SSL public certificate file
+                                   # (change requires restart)
+#ssl_ca_cert = ''
+                                   # Path to a single PEM format file
+                                   # containing CA root certificate(s)
+                                   # (change requires restart)
+#ssl_ca_cert_dir = ''
+                                   # Directory containing CA root certificate(s)
+                                   # (change requires restart)
+
+
+#------------------------------------------------------------------------------
+# POOLS
+#------------------------------------------------------------------------------
+
+# - Concurrent session and pool size -
+
+num_init_children = 32
+                                   # Number of concurrent sessions allowed
+                                   # (change requires restart)
+max_pool = 4
+                                   # Number of connection pool caches per connection
+                                   # (change requires restart)
+
+# - Life time -
+
+child_life_time = 300
+                                   # Pool exits after being idle for this many seconds
+child_max_connections = 0
+                                   # Pool exits after receiving that many connections
+                                   # 0 means no exit
+connection_life_time = 0
+                                   # Connection to backend closes after being idle for this many seconds
+                                   # 0 means no close
+client_idle_limit = 0
+                                   # Client is disconnected after being idle for that many seconds
+                                   # (even inside an explicit transactions!)
+                                   # 0 means no disconnection
+
+
+#------------------------------------------------------------------------------
+# LOGS
+#------------------------------------------------------------------------------
+
+# - Where to log -
+
+log_destination = 'stderr'
+                                   # Where to log
+                                   # Valid values are combinations of stderr,
+                                   # and syslog. Default to stderr.
+
+# - What to log -
+
+log_line_prefix = '%t: pid %p: '   # printf-style string to output at beginning of each log line.
+
+log_connections = off
+                                   # Log connections
+log_hostname = off
+                                   # Hostname will be shown in ps status
+                                   # and in logs if connections are logged
+log_statement = off
+                                   # Log all statements
+log_per_node_statement = off
+                                   # Log all statements
+                                   # with node and backend informations
+log_standby_delay = 'if_over_threshold'
+                                   # Log standby delay
+                                   # Valid values are combinations of always,
+                                   # if_over_threshold, none
+
+# - Syslog specific -
+
+syslog_facility = 'LOCAL0'
+                                   # Syslog local facility. Default to LOCAL0
+syslog_ident = 'pgpool'
+                                   # Syslog program identification string
+                                   # Default to 'pgpool'
+
+# - Debug -
+
+#log_error_verbosity = default          # terse, default, or verbose messages
+
+#client_min_messages = notice           # values in order of decreasing detail:
+                                        #   debug5
+                                        #   debug4
+                                        #   debug3
+                                        #   debug2
+                                        #   debug1
+                                        #   log
+                                        #   notice
+                                        #   warning
+                                        #   error
+
+#log_min_messages = warning             # values in order of decreasing detail:
+                                        #   debug5
+                                        #   debug4
+                                        #   debug3
+                                        #   debug2
+                                        #   debug1
+                                        #   info
+                                        #   notice
+                                        #   warning
+                                        #   error
+                                        #   log
+                                        #   fatal
+                                        #   panic
+
+#------------------------------------------------------------------------------
+# FILE LOCATIONS
+#------------------------------------------------------------------------------
+
+pid_file_name = '/var/run/pgpool/pgpool.pid'
+                                   # PID file name
+                                   # Can be specified as relative to the"
+                                   # location of pgpool.conf file or
+                                   # as an absolute path
+                                   # (change requires restart)
+logdir = '/tmp'
+                                   # Directory of pgPool status file
+                                   # (change requires restart)
+
+
+#------------------------------------------------------------------------------
+# CONNECTION POOLING
+#------------------------------------------------------------------------------
+
+connection_cache = on
+                                   # Activate connection pools
+                                   # (change requires restart)
+
+                                   # Semicolon separated list of queries
+                                   # to be issued at the end of a session
+                                   # The default is for 8.3 and later
+reset_query_list = 'ABORT; DISCARD ALL'
+                                   # The following one is for 8.2 and before
+#reset_query_list = 'ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT'
+
+
+#------------------------------------------------------------------------------
+# REPLICATION MODE
+#------------------------------------------------------------------------------
+
+replication_mode = off
+                                   # Activate replication mode
+                                   # (change requires restart)
+replicate_select = off
+                                   # Replicate SELECT statements
+                                   # when in replication mode
+                                   # replicate_select is higher priority than
+                                   # load_balance_mode.
+
+insert_lock = off
+                                   # Automatically locks a dummy row or a table
+                                   # with INSERT statements to keep SERIAL data
+                                   # consistency
+                                   # Without SERIAL, no lock will be issued
+lobj_lock_table = ''
+                                   # When rewriting lo_creat command in
+                                   # replication mode, specify table name to
+                                   # lock
+
+# - Degenerate handling -
+
+replication_stop_on_mismatch = off
+                                   # On disagreement with the packet kind
+                                   # sent from backend, degenerate the node
+                                   # which is most likely "minority"
+                                   # If off, just force to exit this session
+
+failover_if_affected_tuples_mismatch = off
+                                   # On disagreement with the number of affected
+                                   # tuples in UPDATE/DELETE queries, then
+                                   # degenerate the node which is most likely
+                                   # "minority".
+                                   # If off, just abort the transaction to
+                                   # keep the consistency
+
+
+#------------------------------------------------------------------------------
+# LOAD BALANCING MODE
+#------------------------------------------------------------------------------
+
+load_balance_mode = on
+                                   # Activate load balancing mode
+                                   # (change requires restart)
+ignore_leading_white_space = on
+                                   # Ignore leading white spaces of each query
+white_function_list = ''
+                                   # Comma separated list of function names
+                                   # that don't write to database
+                                   # Regexp are accepted
+black_function_list = 'currval,lastval,nextval,setval'
+                                   # Comma separated list of function names
+                                   # that write to database
+                                   # Regexp are accepted
+
+database_redirect_preference_list = ''
+                                                                  # comma separated list of pairs of database and node id.
+                                                                  # example: postgres:primary,mydb[0-4]:1,mydb[5-9]:2'
+                                                                  # valid for streaming replicaton mode only.
+
+app_name_redirect_preference_list = ''
+                                                                  # comma separated list of pairs of app name and node id.
+                                                                  # example: 'psql:primary,myapp[0-4]:1,myapp[5-9]:standby'
+                                                                  # valid for streaming replicaton mode only.
+allow_sql_comments = off
+                                                                  # if on, ignore SQL comments when judging if load balance or
+                                                                  # query cache is possible.
+                                                                  # If off, SQL comments effectively prevent the judgment
+                                                                  # (pre 3.4 behavior).
+
+#------------------------------------------------------------------------------
+# MASTER/SLAVE MODE
+#------------------------------------------------------------------------------
+
+master_slave_mode = on
+                                   # Activate master/slave mode
+                                   # (change requires restart)
+master_slave_sub_mode = 'logical'
+                                   # Master/slave sub mode
+                                  # Valid values are combinations stream, slony
+                                   # or logical. Default is stream.
+                                   # (change requires restart)
+
+# - Streaming -
+
+sr_check_period = 0
+                                   # Streaming replication check period
+                                   # Disabled (0) by default
+sr_check_user = 'nobody'
+                                   # Streaming replication check user
+                                   # This is neccessary even if you disable streaming
+                                   # replication delay check by sr_check_period = 0
+sr_check_password = ''
+                                   # Password for streaming replication check user
+sr_check_database = 'postgres'
+                                   # Database name for streaming replication check
+delay_threshold = 10000000
+                                   # Threshold before not dispatching query to standby node
+                                   # Unit is in bytes
+                                   # Disabled (0) by default
+
+# - Special commands -
+
+follow_master_command = ''
+                                   # Executes this command after master failover
+                                   # Special values:
+                                   #   %d = node id
+                                   #   %h = host name
+                                   #   %p = port number
+                                   #   %D = database cluster path
+                                   #   %m = new master node id
+                                   #   %H = hostname of the new master node
+                                   #   %M = old master node id
+                                   #   %P = old primary node id
+                                                                  #   %r = new master port number
+                                                                  #   %R = new master database cluster path
+                                   #   %% = '%' character
+
+#------------------------------------------------------------------------------
+# HEALTH CHECK GLOBAL PARAMETERS
+#------------------------------------------------------------------------------
+
+health_check_period = 0
+                                   # Health check period
+                                   # Disabled (0) by default
+health_check_timeout = 20
+                                   # Health check timeout
+                                   # 0 means no timeout
+health_check_user = 'nobody'
+                                   # Health check user
+health_check_password = ''
+                                   # Password for health check user
+health_check_database = ''
+                                   # Database name for health check. If '', tries 'postgres' frist, 
+health_check_max_retries = 0
+                                   # Maximum number of times to retry a failed health check before giving up.
+health_check_retry_delay = 1
+                                   # Amount of time to wait (in seconds) between retries.
+connect_timeout = 10000
+                                   # Timeout value in milliseconds before giving up to connect to backend.
+                                                                  # Default is 10000 ms (10 second). Flaky network user may want to increase
+                                                                  # the value. 0 means no timeout.
+                                                                  # Note that this value is not only used for health check,
+                                                                  # but also for ordinary conection to backend.
+
+#------------------------------------------------------------------------------
+# HEALTH CHECK PER NODE PARAMETERS (OPTIONAL)
+#------------------------------------------------------------------------------
+health_check_period0 = 0
+health_check_timeout0 = 20
+health_check_user0 = 'nobody'
+health_check_password0 = ''
+health_check_database0 = ''
+health_check_max_retries0 = 0
+health_check_retry_delay0 = 1
+connect_timeout0 = 10000
+
+#------------------------------------------------------------------------------
+# FAILOVER AND FAILBACK
+#------------------------------------------------------------------------------
+
+failover_command = ''
+                                   # Executes this command at failover
+                                   # Special values:
+                                   #   %d = node id
+                                   #   %h = host name
+                                   #   %p = port number
+                                   #   %D = database cluster path
+                                   #   %m = new master node id
+                                   #   %H = hostname of the new master node
+                                   #   %M = old master node id
+                                   #   %P = old primary node id
+                                                                  #   %r = new master port number
+                                                                  #   %R = new master database cluster path
+                                   #   %% = '%' character
+failback_command = ''
+                                   # Executes this command at failback.
+                                   # Special values:
+                                   #   %d = node id
+                                   #   %h = host name
+                                   #   %p = port number
+                                   #   %D = database cluster path
+                                   #   %m = new master node id
+                                   #   %H = hostname of the new master node
+                                   #   %M = old master node id
+                                   #   %P = old primary node id
+                                                                  #   %r = new master port number
+                                                                  #   %R = new master database cluster path
+                                   #   %% = '%' character
+
+fail_over_on_backend_error = on
+                                   # Initiates failover when reading/writing to the
+                                   # backend communication socket fails
+                                   # If set to off, pgpool will report an
+                                   # error and disconnect the session.
+
+search_primary_node_timeout = 300
+                                   # Timeout in seconds to search for the
+                                   # primary node when a failover occurs.
+                                   # 0 means no timeout, keep searching
+                                   # for a primary node forever.
+
+#------------------------------------------------------------------------------
+# ONLINE RECOVERY
+#------------------------------------------------------------------------------
+
+recovery_user = 'nobody'
+                                   # Online recovery user
+recovery_password = ''
+                                   # Online recovery password
+recovery_1st_stage_command = ''
+                                   # Executes a command in first stage
+recovery_2nd_stage_command = ''
+                                   # Executes a command in second stage
+recovery_timeout = 90
+                                   # Timeout in seconds to wait for the
+                                   # recovering node's postmaster to start up
+                                   # 0 means no wait
+client_idle_limit_in_recovery = 0
+                                   # Client is disconnected after being idle
+                                   # for that many seconds in the second stage
+                                   # of online recovery
+                                   # 0 means no disconnection
+                                   # -1 means immediate disconnection
+
+
+#------------------------------------------------------------------------------
+# WATCHDOG
+#------------------------------------------------------------------------------
+
+# - Enabling -
+
+use_watchdog = off
+                                    # Activates watchdog
+                                    # (change requires restart)
+
+# -Connection to up stream servers -
+
+trusted_servers = ''
+                                    # trusted server list which are used
+                                    # to confirm network connection
+                                    # (hostA,hostB,hostC,...)
+                                    # (change requires restart)
+ping_path = '/bin'
+                                    # ping command path
+                                    # (change requires restart)
+
+# - Watchdog communication Settings -
+
+wd_hostname = ''
+                                    # Host name or IP address of this watchdog
+                                    # (change requires restart)
+wd_port = 9000
+                                    # port number for watchdog service
+                                    # (change requires restart)
+wd_priority = 1
+                                                                       # priority of this watchdog in leader election
+                                                                       # (change requires restart)
+
+wd_authkey = ''
+                                    # Authentication key for watchdog communication
+                                    # (change requires restart)
+
+wd_ipc_socket_dir = '/tmp'
+                                                                       # Unix domain socket path for watchdog IPC socket
+                                                                       # The Debian package defaults to
+                                                                       # /var/run/postgresql
+                                                                       # (change requires restart)
+
+
+# - Virtual IP control Setting -
+
+delegate_IP = ''
+                                    # delegate IP address
+                                    # If this is empty, virtual IP never bring up. 
+                                    # (change requires restart)
+if_cmd_path = '/sbin'
+                                    # path to the directory where if_up/down_cmd exists 
+                                    # (change requires restart)
+if_up_cmd = 'ip addr add $_IP_$/24 dev eth0 label eth0:0'
+                                    # startup delegate IP command
+                                    # (change requires restart)
+if_down_cmd = 'ip addr del $_IP_$/24 dev eth0'
+                                    # shutdown delegate IP command
+                                    # (change requires restart)
+arping_path = '/usr/sbin'
+                                    # arping command path
+                                    # (change requires restart)
+arping_cmd = 'arping -U $_IP_$ -w 1'
+                                    # arping command
+                                    # (change requires restart)
+
+# - Behaivor on escalation Setting -
+
+clear_memqcache_on_escalation = on
+                                    # Clear all the query cache on shared memory
+                                    # when standby pgpool escalate to active pgpool
+                                    # (= virtual IP holder).
+                                    # This should be off if client connects to pgpool
+                                    # not using virtual IP.
+                                    # (change requires restart)
+wd_escalation_command = ''
+                                    # Executes this command at escalation on new active pgpool.
+                                    # (change requires restart)
+wd_de_escalation_command = ''
+                                                                       # Executes this command when master pgpool resigns from being master.
+                                                                       # (change requires restart)
+
+# - Lifecheck Setting -
+
+# -- common --
+
+wd_monitoring_interfaces_list = ''  # Comma separated list of interfaces names to monitor.
+                                                                       # if any interface from the list is active the watchdog will
+                                                                       # consider the network is fine
+                                                                       # 'any' to enable monitoring on all interfaces except loopback
+                                                                       # '' to disable monitoring
+
+wd_lifecheck_method = 'heartbeat'
+                                    # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external')
+                                    # (change requires restart)
+wd_interval = 10
+                                    # lifecheck interval (sec) > 0
+                                    # (change requires restart)
+
+# -- heartbeat mode --
+
+wd_heartbeat_port = 9694
+                                    # Port number for receiving heartbeat signal
+                                    # (change requires restart)
+wd_heartbeat_keepalive = 2
+                                    # Interval time of sending heartbeat signal (sec)
+                                    # (change requires restart)
+wd_heartbeat_deadtime = 30
+                                    # Deadtime interval for heartbeat signal (sec)
+                                    # (change requires restart)
+heartbeat_destination0 = 'host0_ip1'
+                                    # Host name or IP address of destination 0
+                                    # for sending heartbeat signal.
+                                    # (change requires restart)
+heartbeat_destination_port0 = 9694 
+                                    # Port number of destination 0 for sending
+                                    # heartbeat signal. Usually this is the
+                                    # same as wd_heartbeat_port.
+                                    # (change requires restart)
+heartbeat_device0 = ''
+                                    # Name of NIC device (such like 'eth0')
+                                    # used for sending/receiving heartbeat
+                                    # signal to/from destination 0.
+                                    # This works only when this is not empty
+                                    # and pgpool has root privilege.
+                                    # (change requires restart)
+
+#heartbeat_destination1 = 'host0_ip2'
+#heartbeat_destination_port1 = 9694
+#heartbeat_device1 = ''
+
+# -- query mode --
+
+wd_life_point = 3
+                                    # lifecheck retry times
+                                    # (change requires restart)
+wd_lifecheck_query = 'SELECT 1'
+                                    # lifecheck query to pgpool from watchdog
+                                    # (change requires restart)
+wd_lifecheck_dbname = 'template1'
+                                    # Database name connected for lifecheck
+                                    # (change requires restart)
+wd_lifecheck_user = 'nobody'
+                                    # watchdog user monitoring pgpools in lifecheck
+                                    # (change requires restart)
+wd_lifecheck_password = ''
+                                    # Password for watchdog user in lifecheck
+                                    # (change requires restart)
+
+# - Other pgpool Connection Settings -
+
+#other_pgpool_hostname0 = 'host0'
+                                    # Host name or IP address to connect to for other pgpool 0
+                                    # (change requires restart)
+#other_pgpool_port0 = 5432
+                                    # Port number for othet pgpool 0
+                                    # (change requires restart)
+#other_wd_port0 = 9000
+                                    # Port number for othet watchdog 0
+                                    # (change requires restart)
+#other_pgpool_hostname1 = 'host1'
+#other_pgpool_port1 = 5432
+#other_wd_port1 = 9000
+
+
+#------------------------------------------------------------------------------
+# OTHERS
+#------------------------------------------------------------------------------
+relcache_expire = 0
+                                   # Life time of relation cache in seconds.
+                                   # 0 means no cache expiration(the default).
+                                   # The relation cache is used for cache the
+                                   # query result against PostgreSQL system
+                                   # catalog to obtain various information
+                                   # including table structures or if it's a
+                                   # temporary table or not. The cache is
+                                   # maintained in a pgpool child local memory
+                                   # and being kept as long as it survives.
+                                   # If someone modify the table by using
+                                   # ALTER TABLE or some such, the relcache is
+                                   # not consistent anymore.
+                                   # For this purpose, cache_expiration
+                                   # controls the life time of the cache.
+relcache_size = 256
+                                   # Number of relation cache
+                                   # entry. If you see frequently:
+                                                                  # "pool_search_relcache: cache replacement happend"
+                                                                  # in the pgpool log, you might want to increate this number.
+
+check_temp_table = on
+                                   # If on, enable temporary table check in SELECT statements.
+                                   # This initiates queries against system catalog of primary/master
+                                                                  # thus increases load of master.
+                                                                  # If you are absolutely sure that your system never uses temporary tables
+                                                                  # and you want to save access to primary/master, you could turn this off.
+                                                                  # Default is on.
+
+check_unlogged_table = on
+                                   # If on, enable unlogged table check in SELECT statements.
+                                   # This initiates queries against system catalog of primary/master
+                                   # thus increases load of master.
+                                   # If you are absolutely sure that your system never uses unlogged tables
+                                   # and you want to save access to primary/master, you could turn this off.
+                                   # Default is on.
+
+#------------------------------------------------------------------------------
+# IN MEMORY QUERY MEMORY CACHE
+#------------------------------------------------------------------------------
+memory_cache_enabled = off
+                                                                  # If on, use the memory cache functionality, off by default
+memqcache_method = 'shmem'
+                                                                  # Cache storage method. either 'shmem'(shared memory) or
+                                                                  # 'memcached'. 'shmem' by default
+                                   # (change requires restart)
+memqcache_memcached_host = 'localhost'
+                                                                  # Memcached host name or IP address. Mandatory if
+                                                                  # memqcache_method = 'memcached'.
+                                                                  # Defaults to localhost.
+                                   # (change requires restart)
+memqcache_memcached_port = 11211
+                                                                  # Memcached port number. Mondatory if memqcache_method = 'memcached'.
+                                                                  # Defaults to 11211.
+                                   # (change requires restart)
+memqcache_total_size = 67108864
+                                                                  # Total memory size in bytes for storing memory cache.
+                                                                  # Mandatory if memqcache_method = 'shmem'.
+                                                                  # Defaults to 64MB.
+                                   # (change requires restart)
+memqcache_max_num_cache = 1000000
+                                                                  # Total number of cache entries. Mandatory
+                                                                  # if memqcache_method = 'shmem'.
+                                                                  # Each cache entry consumes 48 bytes on shared memory.
+                                                                  # Defaults to 1,000,000(45.8MB).
+                                   # (change requires restart)
+memqcache_expire = 0
+                                                                  # Memory cache entry life time specified in seconds.
+                                                                  # 0 means infinite life time. 0 by default.
+                                   # (change requires restart)
+memqcache_auto_cache_invalidation = on
+                                                                  # If on, invalidation of query cache is triggered by corresponding
+                                                                  # DDL/DML/DCL(and memqcache_expire).  If off, it is only triggered
+                                                                  # by memqcache_expire.  on by default.
+                                   # (change requires restart)
+memqcache_maxcache = 409600
+                                                                  # Maximum SELECT result size in bytes.
+                                                                  # Must be smaller than memqcache_cache_block_size. Defaults to 400KB.
+                                   # (change requires restart)
+memqcache_cache_block_size = 1048576
+                                                                  # Cache block size in bytes. Mandatory if memqcache_method = 'shmem'.
+                                                                  # Defaults to 1MB.
+                                   # (change requires restart)
+memqcache_oiddir = '/var/log/pgpool/oiddir'
+                                                                  # Temporary work directory to record table oids
+                                   # (change requires restart)
+white_memqcache_table_list = ''
+                                   # Comma separated list of table names to memcache
+                                   # that don't write to database
+                                   # Regexp are accepted
+black_memqcache_table_list = ''
+                                   # Comma separated list of table names not to memcache
+                                   # that don't write to database
+                                   # Regexp are accepted
index 601c8a61521c24a383228455db76d1985bafb4df..24757d2d5997505bebed374b35e67dca3a3e0aa4 100644 (file)
@@ -320,8 +320,8 @@ master_slave_mode = on
                                    # (change requires restart)
 master_slave_sub_mode = 'slony'
                                    # Master/slave sub mode
-                                   # Valid values are combinations slony or
-                                   # stream. Default is slony.
+                                   # Valid values are combinations stream, slony
+                                   # or logical. Default is stream.
                                    # (change requires restart)
 
 # - Streaming -
index f47a7957cf7e495fdbbc74cb54cc738975b4b46f..3318753a649513afe68e7fbd80d88e880b1eee17 100644 (file)
@@ -319,8 +319,8 @@ master_slave_mode = off
                                    # (change requires restart)
 master_slave_sub_mode = 'slony'
                                    # Master/slave sub mode
-                                   # Valid values are combinations slony or
-                                   # stream. Default is slony.
+                                   # Valid values are combinations stream, slony
+                                   # or logical. Default is stream.
                                    # (change requires restart)
 
 # - Streaming -
index 53a87cbf389a77aec46eb35954e9b7a463da3756..a4effb68f800561c7067bf575b6da1c2aacdd1e1 100644 (file)
@@ -321,8 +321,8 @@ master_slave_mode = on
                                    # (change requires restart)
 master_slave_sub_mode = 'stream'
                                    # Master/slave sub mode
-                                   # Valid values are combinations slony or
-                                   # stream. Default is slony.
+                                   # Valid values are combinations stream, slony
+                                   # or logical. Default is stream.
                                    # (change requires restart)
 
 # - Streaming -
index a9ccab7d9793bc88e73a07a2a656f00d9b992c9f..8f11cae0a88b13507b3950fc765e2fe9f5c2a04b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2013-2016 PgPool Global Development Group
+# Copyright (c) 2013-2017 PgPool Global Development Group
 #
 # Permission to use, copy, modify, and distribute this software and
 # its documentation for any purpose and without fee is hereby
 # directory for *testing* purpose.
 # Do not use this tool for production environment!
 #
-# usage: pgpool_setup [-m r|s|n][-n num_clusters][-p base_port][-pg pg_base_port][--no-stop][-d]
+# usage: pgpool_setup [-m r|s|n|l][-n num_clusters][-p base_port][-pg pg_base_port][--no-stop][-d]
 # -m s: create an installation as streaming replication mode.
 # (the default)
 # -m r: create an installation as native replication mode.
 # -m n: create an installation as raw mode.
+# -m l: create an installation as logical replication mode.
 # -n num_clusters: create num_clusters PostgreSQL database cluster nodes
 # -p base_port: specify base port. pgpool port is base_port.
 #  pcp port is base_port + 1. The first PostgreSQL node's port is
@@ -291,10 +292,13 @@ function set_postgresql_conf
                echo "max_wal_senders = $NUMCLUSTERS" >> $PGCONF
                echo "archive_mode = on" >> $PGCONF
                echo "archive_command = 'cp %p $BASEDIR/archivedir/%f </dev/null'" >> $PGCONF
-       elif [ $MODE = 'r' ];then
+       elif [ $MODE = 'r' -o $MODE = 'l' ];then
                echo "wal_level = archive" >> $PGCONF
                echo "archive_mode = on" >> $PGCONF
                echo "archive_command = 'cp %p $BASEDIR/archivedir/%f </dev/null'" >> $PGCONF
+               if [ $MODE = 'l' ];then
+                   echo "wal_level = logical" >> $PGCONF
+               fi
        fi
 
        ed $1/pg_hba.conf <<EOF
@@ -558,7 +562,7 @@ function wait_for_pgpool_reload {
 ################################################################################
 function usage()
 {
-       echo "usage: $0 [-m r|s|n] [-n num_clusters] [-p base_port] [-pg pg_base_port][--no-stop] [-d]";exit 1
+       echo "usage: $0 [-m r|s|n|l] [-n num_clusters] [-p base_port] [-pg pg_base_port][--no-stop] [-d]";exit 1
 }
 
 #-------------------------------------------
@@ -578,6 +582,7 @@ do
                        r ) MODE="r";;
                        s ) MODE="s";;
                        n ) MODE="n";;
+                       l ) MODE="l";;
                        * ) usage;;
                esac
        elif [ $1 = "-n" ];then
@@ -615,6 +620,9 @@ case $MODE in
        n ) MODENAME="raw mode"
                SAMPLE_CONF=$PGPOOLDIR/pgpool.conf.sample
                ;;
+       l ) MODENAME="logical replication mode"
+           SAMPLE_CONF=$PGPOOLDIR/pgpool.conf.sample-logical
+           ;;
 esac
 
 #-------------------------------------------
@@ -828,10 +836,29 @@ else
 
        while [ $n -lt $NUMCLUSTERS ]
        do
+           if [ $MODE = 'l' ]
+           then
+               # temporarily start data$n cluster to create extensions
+               echo "temporarily start data${n} cluster to create extensions"
+               $PG_CTL -w -D data${n} start >&5 2>&1
+               $PSQL -p `expr $BASEPORT + $n` template1 >&5 2>&1 <<EOF
+CREATE EXTENSION pgpool_regclass;
+CREATE EXTENSION pgpool_recovery;
+CREATE DATABASE test;
+EOF
+               $PG_CTL -m f -D data${n} stop >&5 2>&1
+           fi
+
        # set up pgpool.conf
                echo "backend_hostname$n = '$PGSOCKET_DIR'" >> $CONF
                echo "backend_port$n = $PORT" >> $CONF
                echo "backend_weight$n = 1" >> $CONF
+
+               if [ $n -eq 0 -a $MODE = "l" ]
+               then
+                   echo "backend_flag$n = ALWAYS_MASTER" >> $CONF
+               fi
+
                CLUSTER="data"`expr $n`
                CLUSTERDIR=$BASEDIR/$CLUSTER
                echo "backend_data_directory$n = '$CLUSTERDIR'" >> $CONF