<!-- doc/src/sgml/config.sgml -->

<sect1 id="runtime-streaming-replication-check">
  <title>Streaming Replication Check</title>

  <para>
    <productname>Pgpool-II</productname> can work with <productname>PostgreSQL</> native
    Streaming Replication, that is available since <productname>PostgreSQL</> 9.0.
    To configure <productname>Pgpool-II</productname> with streaming
    replication, enable <xref linkend="guc-master-slave-mode"> and set
    <xref linkend="guc-master-slave-sub-mode"> to <literal>'stream'</literal>.
  </para>
  <para>
    <productname>Pgpool-II</productname> assumes that Streaming Replication
    is configured with Hot Standby on PostgreSQL, which means that the
    standby database can handle read-only queries.
  </para>

  <variablelist>

    <varlistentry id="guc-sr-check-period" xreflabel="sr_check_period">
      <term><varname>sr_check_period</varname> (<type>integer</type>)
        <indexterm>
          <primary><varname>sr_check_period</varname> configuration parameter</primary>
        </indexterm>
      </term>
      <listitem>

        <para>
          Specifies the time interval in seconds to check the streaming
          replication delay.
          Default is 0, which means the check is disabled.
        </para>

        <para>
          This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
        </para>

      </listitem>
    </varlistentry>

    <varlistentry id="guc-sr-check-user" xreflabel="sr_check_user">
      <term><varname>sr_check_user</varname> (<type>string</type>)
        <indexterm>
          <primary><varname>sr_check_user</varname> configuration parameter</primary>
        </indexterm>
      </term>
      <listitem>

        <para>
          Specifies the <productname>PostgreSQL</> user name to perform streaming replication check.
          The user must exist on all the <productname>PostgreSQL</> backends.
        </para>
        <note>
          <para>
            <varname>sr_check_user</varname>> and <xref linkend="guc-sr-check-password">
            are used even when <xref linkend="guc-sr-check-period"> is set to 0 (disabled)
            for the identification of the primary server.
          </para>
        </note>

        <para>
          This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
        </para>

      </listitem>
    </varlistentry>

    <varlistentry id="guc-sr-check-password" xreflabel="sr_check_password">
      <term><varname>sr_check_password</varname> (<type>string</type>)
        <indexterm>
          <primary><varname>sr_check_password</varname> configuration parameter</primary>
        </indexterm>
      </term>
      <listitem>

        <para>
          Specifies the password of the <xref linkend="guc-sr-check-user"> <productname>PostgreSQL</> user
          to perform the streaming replication checks.
          Use <literal>''</literal> (empty string) if the user does not requires a password.
        </para>

        <para>
          This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
        </para>

      </listitem>
    </varlistentry>

    <varlistentry id="guc-sr-check-database" xreflabel="sr_check_database">
      <term><varname>sr_check_database</varname> (<type>string</type>)
        <indexterm>
          <primary><varname>sr_check_database</varname> configuration parameter</primary>
        </indexterm>
      </term>
      <listitem>

        <para>
          Specifies the database to perform streaming replication delay checks.
          The default is <literal>"postgres"</literal>.
        </para>
        <para>
          This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
        </para>

      </listitem>
    </varlistentry>

    <varlistentry id="guc-delay-threshold" xreflabel="delay_threshold">
      <term><varname>delay_threshold</varname> (<type>integer</type>)
        <indexterm>
          <primary><varname>delay_threshold</varname> configuration parameter</primary>
        </indexterm>
      </term>
      <listitem>

        <para>
          Specifies the maximum tolerance level of replication delay in
          <acronym>WAL</acronym> bytes on the standby server against the
          primary server. If the delay exceeds this configured level,
          <productname>Pgpool-II</productname> stops sending the <acronym>
          SELECT</acronym> queries to the standby server and starts routing
          everything to the primary server even if <xref linkend="guc-load-balance-mode">
          is enabled, until the standby catches-up with the primary.
          Setting this parameter to 0 disables the delay checking.
          This delay threshold check is performed every <xref linkend="guc-sr-check-period">.
          Default is 0.
        </para>

        <para>
          This parameter can be changed by reloading the <productname>Pgpool-II conf</>igurations.
        </para>

      </listitem>
    </varlistentry>

    <varlistentry id="guc-log-standby-delay" xreflabel="log_standby_delay">
      <term><varname>log_standby_delay</varname> (<type>string</type>)
        <indexterm>
          <primary><varname>log_standby_delay</varname> configuration parameter</primary>
        </indexterm>
      </term>
      <listitem>

        <para>
          Specifies when to log the replication delay. Below table contains the list
          of all valid values for the parameter.
        </para>

        <table id="log-standby-delay-table">
          <title>Log standby delay options</title>
          <tgroup cols="2">
            <thead>
              <row>
                <entry>Value</entry>
                <entry>Description</entry>
              </row>
            </thead>

            <tbody>
              <row>
                <entry><literal>'none'</literal></entry>
                <entry>Never log the standby delay</entry>
              </row>

              <row>
                <entry><literal>'always'</literal></entry>
                <entry>Log the standby delay, every time the replication delay is checked</entry>
              </row>

              <row>
                <entry><literal>'if_over_threshold'</literal></entry>
                <entry>Only log the standby delay, when it exceeds <xref linkend="guc-delay-threshold"> value</entry>
              </row>
            </tbody>
          </tgroup>
        </table>

        <para>
          This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
        </para>

      </listitem>
    </varlistentry>

  </variablelist>

</sect1>
