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 $ -->
2
2
3
3
<chapter id="high-availability">
4
4
<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'
1056
1056
is useful for both log shipping replication and for restoring a backup
1057
1057
to an exact state with great precision.
1058
1058
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 .
1061
1061
</para>
1062
1062
1063
1063
<para>
@@ -1082,7 +1082,7 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1082
1082
return differing results. Eventually, the standby will be
1083
1083
consistent with the primary.
1084
1084
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
1086
1086
in the case of serializable transactions. In comparison with the primary,
1087
1087
the standby returns query results that could have been obtained on the primary
1088
1088
at some moment in the past.
@@ -1103,8 +1103,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1103
1103
</para>
1104
1104
1105
1105
<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
1108
1108
work files.
1109
1109
</para>
1110
1110
@@ -1203,10 +1203,14 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1203
1203
</listitem>
1204
1204
<listitem>
1205
1205
<para>
1206
- <command>LOCK TABLE</>, in short default form, since it requests <literal>ACCESS EXCLUSIVE MODE</>.
1207
1206
<command>LOCK TABLE</> that explicitly requests a mode higher than <literal>ROW EXCLUSIVE MODE</>.
1208
1207
</para>
1209
1208
</listitem>
1209
+ <listitem>
1210
+ <para>
1211
+ <command>LOCK TABLE</> in short default form, since it requests <literal>ACCESS EXCLUSIVE MODE</>.
1212
+ </para>
1213
+ </listitem>
1210
1214
<listitem>
1211
1215
<para>
1212
1216
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'
1241
1245
</listitem>
1242
1246
<listitem>
1243
1247
<para>
1244
- sequence update - nextval()
1248
+ Sequence update - <function> nextval()</>
1245
1249
</para>
1246
1250
</listitem>
1247
1251
<listitem>
@@ -1253,9 +1257,9 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1253
1257
</para>
1254
1258
1255
1259
<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
1257
1261
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
1259
1263
run on a standby and run during normal operation.
1260
1264
It is possible that <command>LISTEN</>, <command>UNLISTEN</>,
1261
1265
<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'
1275
1279
issuing <command>SHOW transaction_read_only</>. In addition, a set of
1276
1280
functions (<xref linkend="functions-recovery-info-table">) allow users to
1277
1281
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
1279
1283
can be used to monitor the progress of recovery, or to allow you to
1280
1284
write complex programs that restore the database to particular states.
1281
1285
</para>
@@ -1338,7 +1342,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1338
1342
</listitem>
1339
1343
<listitem>
1340
1344
<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.
1342
1347
</para>
1343
1348
</listitem>
1344
1349
<listitem>
@@ -1350,27 +1355,28 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1350
1355
</para>
1351
1356
1352
1357
<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.
1363
1369
</para>
1364
1370
1365
1371
<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
1367
1373
running <command>DROP TABLE</> on a table that is currently being queried
1368
1374
on the standby server.
1369
1375
Clearly the query cannot continue if <command>DROP TABLE</>
1370
1376
proceeds. If this situation occurred on the primary, the <command>DROP TABLE</>
1371
1377
would wait until the query had finished. When <command>DROP TABLE</> is
1372
1378
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
1374
1380
cannot wait for any of the standby queries. The WAL change records come through to the
1375
1381
standby while the standby query is still running, causing a conflict.
1376
1382
</para>
@@ -1407,8 +1413,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1407
1413
<para>
1408
1414
If the conflict is caused by a lock, the conflicting standby
1409
1415
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.
1412
1418
</para>
1413
1419
</listitem>
1414
1420
@@ -1456,12 +1462,13 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1456
1462
for as long as needed to run queries on the standby. This guarantees that
1457
1463
a WAL cleanup record is never generated and query conflicts do not occur,
1458
1464
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.
1465
1472
</para>
1466
1473
1467
1474
<para>
@@ -1494,8 +1501,10 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
1494
1501
be disabled via <filename>postgresql.conf</>. The server might take
1495
1502
some time to enable recovery connections since the server must first complete
1496
1503
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:
1499
1508
1500
1509
<programlisting>
1501
1510
LOG: entering standby mode
@@ -1617,9 +1626,9 @@ LOG: database system is ready to accept read only connections
1617
1626
1618
1627
<para>
1619
1628
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
1623
1632
standby.
1624
1633
</para>
1625
1634
@@ -1646,12 +1655,12 @@ LOG: database system is ready to accept read only connections
1646
1655
1647
1656
<para>
1648
1657
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.
1652
1661
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.
1655
1664
</para>
1656
1665
1657
1666
<para>
@@ -1715,7 +1724,7 @@ LOG: database system is ready to accept read only connections
1715
1724
In normal (non-recovery) mode, if you issue <command>DROP USER</> or <command>DROP ROLE</>
1716
1725
for a role with login capability while that user is still connected then
1717
1726
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
1719
1728
<command>DROP USER</> on the primary does not disconnect that user on the standby.
1720
1729
</para>
1721
1730
@@ -1729,15 +1738,15 @@ LOG: database system is ready to accept read only connections
1729
1738
</para>
1730
1739
1731
1740
<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.
1734
1743
</para>
1735
1744
1736
1745
<para>
1737
1746
The background writer is active during recovery and will perform
1738
1747
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.
1741
1750
The <command>CHECKPOINT</> command is accepted during recovery,
1742
1751
though it performs a restartpoint rather than a new checkpoint.
1743
1752
</para>
@@ -1792,11 +1801,15 @@ LOG: database system is ready to accept read only connections
1792
1801
<para>
1793
1802
Valid starting points for recovery connections are generated at each
1794
1803
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.
1800
1813
</para>
1801
1814
</listitem>
1802
1815
<listitem>
0 commit comments