Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fd3499b

Browse files
committed
Some copy-editing of the Hot Standby documentation.
Thanks to Joshua Tolley for the review.
1 parent dedb500 commit fd3499b

File tree

1 file changed

+48
-69
lines changed

1 file changed

+48
-69
lines changed

doc/src/sgml/high-availability.sgml

Lines changed: 48 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/high-availability.sgml,v 1.74 2010/06/22 02:57:50 rhaas Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/high-availability.sgml,v 1.75 2010/06/24 19:50:25 rhaas Exp $ -->
22

33
<chapter id="high-availability">
44
<title>High Availability, Load Balancing, and Replication</title>
@@ -1150,52 +1150,32 @@ if (!triggered)
11501150
<title>User's Overview</title>
11511151

11521152
<para>
1153-
Users can connect to the database server while it is in recovery
1154-
mode and perform read-only queries. Read-only access to system
1155-
catalogs and views will also occur as normal.
1153+
When the <xref linkend="guc-hot-standby"> parameter is set to true on a
1154+
standby server, it will begin accepting connections once the recovery has
1155+
brought the system to a consistent state. All such connections are
1156+
strictly read-only; not even temporary tables may be written.
11561157
</para>
11571158

11581159
<para>
11591160
The data on the standby takes some time to arrive from the primary server
11601161
so there will be a measurable delay between primary and standby. Running the
11611162
same query nearly simultaneously on both primary and standby might therefore
11621163
return differing results. We say that data on the standby is
1163-
<firstterm>eventually consistent</firstterm> with the primary.
1164-
Queries executed on the standby will be correct with regard to the transactions
1165-
that had been recovered at the start of the query, or start of first statement
1166-
in the case of serializable transactions. In comparison with the primary,
1167-
the standby returns query results that could have been obtained on the primary
1168-
at some moment in the past.
1164+
<firstterm>eventually consistent</firstterm> with the primary. Once the
1165+
commit record for a transaction is replayed on the standby, the changes
1166+
made by that transaction will be visible to any new snapshots taken on
1167+
the standby. Snapshots may be taken at the start of each query or at the
1168+
start of each transaction, depending on the current transaction isolation
1169+
level. For more details, see <xref linkend="transaction-iso">.
11691170
</para>
11701171

11711172
<para>
1172-
When a transaction is started in recovery, the parameter
1173-
<varname>transaction_read_only</> will be forced to be true, regardless of the
1174-
<varname>default_transaction_read_only</> setting in <filename>postgresql.conf</>.
1175-
It can't be manually set to false either. As a result, all transactions
1176-
started during recovery will be limited to read-only actions. In all
1177-
other ways, connected sessions will appear identical to sessions
1178-
initiated during normal processing mode. There are no special commands
1179-
required to initiate a connection so all interfaces
1180-
work unchanged. After recovery finishes, the session
1181-
will allow normal read-write transactions at the start of the next
1182-
transaction, if these are requested.
1183-
</para>
1184-
1185-
<para>
1186-
"Read-only" above means no writes to the permanent or temporary database
1187-
tables. There are no problems with queries that use transient sort and
1188-
work files.
1189-
</para>
1190-
1191-
<para>
1192-
The following actions are allowed:
1173+
Transactions started during recovery may issue the following commands:
11931174

11941175
<itemizedlist>
11951176
<listitem>
11961177
<para>
1197-
Query access - <command>SELECT</>, <command>COPY TO</> including views and
1198-
<command>SELECT</> rules
1178+
Query access - <command>SELECT</>, <command>COPY TO</>
11991179
</para>
12001180
</listitem>
12011181
<listitem>
@@ -1251,7 +1231,9 @@ if (!triggered)
12511231
</para>
12521232

12531233
<para>
1254-
These actions produce error messages:
1234+
Transactions started during recovery may never be assigned a transaction ID
1235+
and may not write to the system write-ahead log. Therefore, the following
1236+
actions will produce error messages:
12551237

12561238
<itemizedlist>
12571239
<listitem>
@@ -1260,20 +1242,24 @@ if (!triggered)
12601242
<command>UPDATE</>, <command>DELETE</>, <command>COPY FROM</>,
12611243
<command>TRUNCATE</>.
12621244
Note that there are no allowed actions that result in a trigger
1263-
being executed during recovery.
1245+
being executed during recovery. This restriction applies even to
1246+
temporary tables, because table rows cannot be read or written without
1247+
assigning a transaction ID, which is currently not possible in a
1248+
Hot Standby environment.
12641249
</para>
12651250
</listitem>
12661251
<listitem>
12671252
<para>
12681253
Data Definition Language (DDL) - <command>CREATE</>,
12691254
<command>DROP</>, <command>ALTER</>, <command>COMMENT</>.
1270-
This also applies to temporary tables also because currently their
1271-
definition causes writes to catalog tables.
1255+
This restriction applies even to temporary tables, because carrying
1256+
out these operations would require updating the system catalog tables.
12721257
</para>
12731258
</listitem>
12741259
<listitem>
12751260
<para>
1276-
<command>SELECT ... FOR SHARE | UPDATE</> which cause row locks to be written
1261+
<command>SELECT ... FOR SHARE | UPDATE</>, because row locks cannot be
1262+
taken without updating the underlying data files.
12771263
</para>
12781264
</listitem>
12791265
<listitem>
@@ -1337,20 +1323,22 @@ if (!triggered)
13371323
</para>
13381324

13391325
<para>
1340-
Note that the current behavior of read only transactions when not in
1341-
recovery is to allow the last two actions, so there are small and
1342-
subtle differences in behavior between read-only transactions
1343-
run on a standby and run during normal operation.
1344-
It is possible that <command>LISTEN</>, <command>UNLISTEN</>,
1345-
and temporary tables might be allowed in a future release.
1326+
Outside of recovery, read-only transactions are allowed to update sequences
1327+
and to use <command>LISTEN</>, <command>UNLISTEN</>, and
1328+
<command>NOTIFY</>, so Hot Standby sessions operate under slightly tighter
1329+
restrictions than ordinary read-only sessions. It is possible that some
1330+
of these restrictions might be loosened in a future release.
13461331
</para>
13471332

13481333
<para>
1349-
If failover or switchover occurs the database will switch to normal
1350-
processing mode. Sessions will remain connected while the server
1351-
changes mode. Current transactions will continue, though will remain
1352-
read-only. After recovery is complete, it will be possible to initiate
1353-
read-write transactions.
1334+
During recovery, the parameter <varname>transaction_read_only</> is always
1335+
true and may not be changed. But as long as no attempt is made to modify
1336+
the database, connections during recovery will act much like any other
1337+
database connection. If failover or switchover occurs, the database will
1338+
switch to normal processing mode. Sessions will remain connected while the
1339+
server changes mode. Once recovery finishes, it will be possible to
1340+
initiate read-write transactions (even from a session begun during
1341+
recovery).
13541342
</para>
13551343

13561344
<para>
@@ -1364,15 +1352,7 @@ if (!triggered)
13641352
</para>
13651353

13661354
<para>
1367-
In recovery, transactions will not be permitted to take any table lock
1368-
higher than <literal>RowExclusiveLock</>. In addition, transactions may never assign
1369-
a TransactionId and may never write WAL.
1370-
Any <command>LOCK TABLE</> command that runs on the standby and requests
1371-
a specific lock mode higher than <literal>ROW EXCLUSIVE MODE</> will be rejected.
1372-
</para>
1373-
1374-
<para>
1375-
In general queries will not experience lock conflicts from the database
1355+
In general, queries will not experience lock conflicts from the database
13761356
changes made by recovery. This is because recovery follows normal
13771357
concurrency control mechanisms, known as <acronym>MVCC</>. There are
13781358
some types of change that will cause conflicts, covered in the following
@@ -1397,8 +1377,7 @@ if (!triggered)
13971377
These conflicts are <emphasis>hard conflicts</> in the sense that queries
13981378
might need to be cancelled and, in some cases, sessions disconnected to resolve them.
13991379
The user is provided with several ways to handle these
1400-
conflicts, though it is important to first understand the possible causes
1401-
of conflicts:
1380+
conflicts. Conflicts can be caused by:
14021381

14031382
<itemizedlist>
14041383
<listitem>
@@ -1427,7 +1406,7 @@ if (!triggered)
14271406
</listitem>
14281407
<listitem>
14291408
<para>
1430-
Early cleanup of data still visible to the current query's snapshot
1409+
Early cleanup of data still visible to the current query's snapshot.
14311410
</para>
14321411
</listitem>
14331412
</itemizedlist>
@@ -1503,16 +1482,16 @@ if (!triggered)
15031482
If the conflict is caused by cleanup records, the standby query is informed
15041483
a conflict has occurred and that it must cancel itself to avoid the
15051484
risk that it silently fails to read relevant data because
1506-
that data has been removed. (This is regrettably similar to the
1507-
much feared and iconic error message "snapshot too old"). Some cleanup
1485+
that data has been removed. Some cleanup
15081486
records only conflict with older queries, while others
15091487
can affect all queries.
15101488
</para>
15111489

15121490
<para>
1513-
If cancellation does occur, the query and/or transaction can always
1514-
be re-executed. The error is dynamic and will not necessarily reoccur
1515-
if the query is executed again.
1491+
Cancelled queries may be retried immediately (after beginning a new
1492+
transaction, of course). Since query cancellation depends on
1493+
the nature of the WAL records being replayed, a query that was
1494+
cancelled may succeed if it is executed again.
15161495
</para>
15171496
</listitem>
15181497
</itemizedlist>
@@ -1533,7 +1512,7 @@ if (!triggered)
15331512
<para>
15341513
Be sure that the primary and standby servers' clocks are kept in sync;
15351514
otherwise the values compared to <varname>max_standby_delay</> will be
1536-
erroneous, possibly leading to undesirable query cancellations.
1515+
erroneous, possibly leading to additional query cancellations.
15371516
If the clocks are intentionally not in sync, or if there is a large
15381517
propagation delay from primary to standby, it is advisable to set
15391518
<varname>max_standby_delay</> to -1. In any case the value should be
@@ -1557,10 +1536,10 @@ if (!triggered)
15571536
as described above. This could be done using <filename>contrib/dblink</>
15581537
and <function>pg_sleep()</>, or via other mechanisms. If you do this, you
15591538
should note that this will delay cleanup of dead rows on the primary by
1560-
vacuum or HOT, and people might find this undesirable. However, remember
1539+
vacuum or HOT, which may be undesirable. However, remember
15611540
that the primary and standby nodes are linked via the WAL, so the cleanup
15621541
situation is no different from the case where the query ran on the primary
1563-
node itself. And you are still getting the benefit of off-loading the
1542+
node itself, and you are still getting the benefit of off-loading the
15641543
execution onto the standby. <varname>max_standby_delay</> should
15651544
not be used in this case because delayed WAL files might already
15661545
contain entries that invalidate the current snapshot.

0 commit comments

Comments
 (0)