1- <!-- $PostgreSQL: pgsql/doc/src/sgml/high-availability.sgml,v 1.46 2010/02/18 04:14:38 momjian Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/high-availability.sgml,v 1.47 2010/02/19 00:15:25 momjian Exp $ -->
22
33<chapter id="high-availability">
44 <title>High Availability, Load Balancing, and Replication</title>
@@ -1056,8 +1056,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
10561056 is useful for both log shipping replication and for restoring a backup
10571057 to an exact state with great precision.
10581058 The term Hot Standby also refers to the ability of the server to move
1059- from recovery through to normal running while users continue running
1060- queries and/or continue their connections.
1059+ from recovery through to normal operation while users continue running
1060+ queries and/or keep their connections open .
10611061 </para>
10621062
10631063 <para>
@@ -1082,7 +1082,7 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
10821082 return differing results. Eventually, the standby will be
10831083 consistent with the primary.
10841084 Queries executed on the standby will be correct with regard to the transactions
1085- that had been recovered at the start of the query, or start of first statement,
1085+ that had been recovered at the start of the query, or start of first statement
10861086 in the case of serializable transactions. In comparison with the primary,
10871087 the standby returns query results that could have been obtained on the primary
10881088 at some moment in the past.
@@ -1103,8 +1103,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
11031103 </para>
11041104
11051105 <para>
1106- "Read-only" above means no writes to the permanent database tables.
1107- There are no problems with queries that use transient sort and
1106+ "Read-only" above means no writes to the permanent or temporary database
1107+ tables. There are no problems with queries that use transient sort and
11081108 work files.
11091109 </para>
11101110
@@ -1203,10 +1203,14 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
12031203 </listitem>
12041204 <listitem>
12051205 <para>
1206- <command>LOCK TABLE</>, in short default form, since it requests <literal>ACCESS EXCLUSIVE MODE</>.
12071206 <command>LOCK TABLE</> that explicitly requests a mode higher than <literal>ROW EXCLUSIVE MODE</>.
12081207 </para>
12091208 </listitem>
1209+ <listitem>
1210+ <para>
1211+ <command>LOCK TABLE</> in short default form, since it requests <literal>ACCESS EXCLUSIVE MODE</>.
1212+ </para>
1213+ </listitem>
12101214 <listitem>
12111215 <para>
12121216 Transaction management commands that explicitly set non-read-only state:
@@ -1241,7 +1245,7 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
12411245 </listitem>
12421246 <listitem>
12431247 <para>
1244- sequence update - nextval()
1248+ Sequence update - <function> nextval()</>
12451249 </para>
12461250 </listitem>
12471251 <listitem>
@@ -1253,9 +1257,9 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
12531257 </para>
12541258
12551259 <para>
1256- Note that the current behaviour of read only transactions when not in
1260+ Note that the current behavior of read only transactions when not in
12571261 recovery is to allow the last two actions, so there are small and
1258- subtle differences in behaviour between read-only transactions
1262+ subtle differences in behavior between read-only transactions
12591263 run on a standby and run during normal operation.
12601264 It is possible that <command>LISTEN</>, <command>UNLISTEN</>,
12611265 <command>NOTIFY</>, and temporary tables might be allowed in a
@@ -1275,7 +1279,7 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
12751279 issuing <command>SHOW transaction_read_only</>. In addition, a set of
12761280 functions (<xref linkend="functions-recovery-info-table">) allow users to
12771281 access information about the standby server. These allow you to write
1278- functions that are aware of the current state of the database. These
1282+ programs that are aware of the current state of the database. These
12791283 can be used to monitor the progress of recovery, or to allow you to
12801284 write complex programs that restore the database to particular states.
12811285 </para>
@@ -1338,7 +1342,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
13381342 </listitem>
13391343 <listitem>
13401344 <para>
1341- Waiting to acquire buffer cleanup locks
1345+ The standby waiting longer than <varname>max_standby_delay</>
1346+ to acquire a buffer cleanup lock.
13421347 </para>
13431348 </listitem>
13441349 <listitem>
@@ -1350,27 +1355,28 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
13501355 </para>
13511356
13521357 <para>
1353- Some WAL redo actions will be for <acronym>DDL</> actions. These DDL actions are
1354- repeating actions that have already committed on the primary node, so
1355- they must not fail on the standby node. These DDL locks take priority
1356- and will automatically *cancel* any read-only transactions that get in
1357- their way, after a grace period. This is similar to the possibility of
1358- being canceled by the deadlock detector, but in this case the standby
1359- process always wins, since the replayed actions must not fail. This
1360- also ensures that replication does not fall behind while waiting for a
1361- query to complete. Again, the assumption is that the standby is
1362- primarily for high availability.
1358+ Some WAL redo actions will be for <acronym>DDL</> execution. These DDL
1359+ actions are replaying changes that have already committed on the primary
1360+ node, so they must not fail on the standby node. These DDL locks take
1361+ priority and will automatically *cancel* any read-only transactions that
1362+ get in their way, after a grace period. This is similar to the possibility
1363+ of being canceled by the deadlock detector. But in this case, the standby
1364+ recovery process always wins, since the replayed actions must not fail.
1365+ This also ensures that replication does not fall behind while waiting for a
1366+ query to complete. This prioritization presumes that the standby exists
1367+ primarily for high availability, and that adjusting the grace period
1368+ will allow a sufficient guard against unexpected cancellation.
13631369 </para>
13641370
13651371 <para>
1366- An example of the above would be an Administrator on Primary server
1372+ An example of the above would be an administrator on the primary server
13671373 running <command>DROP TABLE</> on a table that is currently being queried
13681374 on the standby server.
13691375 Clearly the query cannot continue if <command>DROP TABLE</>
13701376 proceeds. If this situation occurred on the primary, the <command>DROP TABLE</>
13711377 would wait until the query had finished. When <command>DROP TABLE</> is
13721378 run on the primary, the primary doesn't have
1373- information about which queries are running on the standby and so
1379+ information about which queries are running on the standby, so it
13741380 cannot wait for any of the standby queries. The WAL change records come through to the
13751381 standby while the standby query is still running, causing a conflict.
13761382 </para>
@@ -1407,8 +1413,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
14071413 <para>
14081414 If the conflict is caused by a lock, the conflicting standby
14091415 transaction is cancelled immediately. If the transaction is
1410- idle-in-transaction then the session is aborted
1411- instead, though this might change in the future.
1416+ idle-in-transaction, then the session is aborted instead.
1417+ This behavior might change in the future.
14121418 </para>
14131419 </listitem>
14141420
@@ -1456,12 +1462,13 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
14561462 for as long as needed to run queries on the standby. This guarantees that
14571463 a WAL cleanup record is never generated and query conflicts do not occur,
14581464 as described above. This could be done using <filename>contrib/dblink</>
1459- and <function>pg_sleep()</>, or via other mechanisms. If you do this, you should note
1460- that this will delay cleanup of dead rows by vacuum or HOT and
1461- people might find this undesirable. However, remember that the
1462- primary and standby nodes are linked via the WAL, so this situation is no
1463- different from the case where the query ran on the primary node itself
1464- except for the benefit of off-loading the execution onto the standby.
1465+ and <function>pg_sleep()</>, or via other mechanisms. If you do this, you
1466+ should note that this will delay cleanup of dead rows on the primary by
1467+ vacuum or HOT, and people might find this undesirable. However, remember
1468+ that the primary and standby nodes are linked via the WAL, so the cleanup
1469+ situation is no different from the case where the query ran on the primary
1470+ node itself. And you are still getting the benefit of off-loading the
1471+ execution onto the standby.
14651472 </para>
14661473
14671474 <para>
@@ -1494,8 +1501,10 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
14941501 be disabled via <filename>postgresql.conf</>. The server might take
14951502 some time to enable recovery connections since the server must first complete
14961503 sufficient recovery to provide a consistent state against which queries
1497- can run before enabling read only connections. Look for these messages
1498- in the server logs:
1504+ can run before enabling read only connections. During this period,
1505+ clients that attempt to connect will be refused with an error message.
1506+ To confirm the server has come up, either loop retrying to connect from
1507+ the application, or look for these messages in the server logs:
14991508
15001509<programlisting>
15011510LOG: entering standby mode
@@ -1617,9 +1626,9 @@ LOG: database system is ready to accept read only connections
16171626
16181627 <para>
16191628 As a result, you cannot create additional indexes that exist solely
1620- on the standby, nor can statistics exist solely on the standby.
1621- If these administration commands are needed they should be executed
1622- on the primary so that the changes will propagate to the
1629+ on the standby, nor statistics that exist solely on the standby.
1630+ If these administration commands are needed, they should be executed
1631+ on the primary, and eventually those changes will propagate to the
16231632 standby.
16241633 </para>
16251634
@@ -1646,12 +1655,12 @@ LOG: database system is ready to accept read only connections
16461655
16471656 <para>
16481657 The <productname>Nagios</> plugin <productname>check_pgsql</> will
1649- work, but it is very simple .
1650- <productname>check_postgres</> will also work, though some actions
1651- could give different or confusing results.
1658+ work, because the simple information it checks for exists .
1659+ The <productname>check_postgres</> monitoring script will also work,
1660+ though some reported values could give different or confusing results.
16521661 For example, last vacuum time will not be maintained, since no
1653- vacuum occurs on the standby (though vacuums running on the primary do
1654- send their changes to the standby) .
1662+ vacuum occurs on the standby. Vacuums running on the primary
1663+ do still send their changes to the standby.
16551664 </para>
16561665
16571666 <para>
@@ -1715,7 +1724,7 @@ LOG: database system is ready to accept read only connections
17151724 In normal (non-recovery) mode, if you issue <command>DROP USER</> or <command>DROP ROLE</>
17161725 for a role with login capability while that user is still connected then
17171726 nothing happens to the connected user - they remain connected. The user cannot
1718- reconnect however. This behaviour applies in recovery also, so a
1727+ reconnect however. This behavior applies in recovery also, so a
17191728 <command>DROP USER</> on the primary does not disconnect that user on the standby.
17201729 </para>
17211730
@@ -1729,15 +1738,15 @@ LOG: database system is ready to accept read only connections
17291738 </para>
17301739
17311740 <para>
1732- Autovacuum is not active during recovery, though it will start normally
1733- at the end of recovery.
1741+ Autovacuum is not active during recovery, it will start normally at the
1742+ end of recovery.
17341743 </para>
17351744
17361745 <para>
17371746 The background writer is active during recovery and will perform
17381747 restartpoints (similar to checkpoints on the primary) and normal block
1739- cleaning activities. (Remember, hint bits will cause blocks to
1740- be modified on the standby server.)
1748+ cleaning activities. This can include updates of the hint bit
1749+ information stored on the standby server.
17411750 The <command>CHECKPOINT</> command is accepted during recovery,
17421751 though it performs a restartpoint rather than a new checkpoint.
17431752 </para>
@@ -1792,11 +1801,15 @@ LOG: database system is ready to accept read only connections
17921801 <para>
17931802 Valid starting points for recovery connections are generated at each
17941803 checkpoint on the master. If the standby is shut down while the master
1795- is in a shutdown state it might not be possible to re-enter Hot Standby
1796- until the primary is started up so that it generates further starting
1797- points in the WAL logs. This is not considered a serious issue
1798- because the standby is usually switched to act as primary when
1799- the first node is taken down.
1804+ is in a shutdown state, it might not be possible to re-enter Hot Standby
1805+ until the primary is started up, so that it generates further starting
1806+ points in the WAL logs. This situation isn't a problem in the most
1807+ common situations where it might happen. Generally, if the primary is
1808+ shut down and not available anymore, that's likely due to a serious
1809+ failure that requires the standby being converted to operate as
1810+ the new primary anyway. And in situations where the primary is
1811+ being intentionally taken down, coordinating to make sure the standby
1812+ becomes the new primary smoothly is also standard procedure.
18001813 </para>
18011814 </listitem>
18021815 <listitem>
0 commit comments