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

Commit a126a95

Browse files
committed
doc: Clarify use of ACCESS EXCLUSIVE lock in various sections
Some sections of the documentation used "exclusive lock" to describe that an ACCESS EXCLUSIVE lock is taken during a given operation. This can be confusing to the reader as ACCESS SHARE is allowed with an EXCLUSIVE lock is used, but that would not be the case with what is described on those parts of the documentation. Author: Greg Rychlewski Discussion: https://postgr.es/m/CAKemG7VptD=7fNWckFMsMVZL_zzvgDO6v2yVmQ+ZiBfc_06kCQ@mail.gmail.com Backpatch-through: 9.6
1 parent 448e86c commit a126a95

9 files changed

+31
-21
lines changed

doc/src/sgml/ddl.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,8 @@ SELECT * FROM information WHERE group_id = 2 FOR UPDATE;
26212621
definer function.) Also, heavy concurrent use of row share locks on the
26222622
referenced table could pose a performance problem, especially if updates
26232623
of it are frequent. Another solution, practical if updates of the
2624-
referenced table are infrequent, is to take an exclusive lock on the
2624+
referenced table are infrequent, is to take an
2625+
<literal>ACCESS EXCLUSIVE</literal> lock on the
26252626
referenced table when updating it, so that no concurrent transactions
26262627
could be examining old row values. Or one could just wait for all
26272628
concurrent transactions to end after committing an update of the

doc/src/sgml/hstore.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ UPDATE tablename SET hstorecol = hstorecol || '';
610610
<programlisting>
611611
ALTER TABLE tablename ALTER hstorecol TYPE hstore USING hstorecol || '';
612612
</programlisting>
613-
The <command>ALTER TABLE</command> method requires an exclusive lock on the table,
613+
The <command>ALTER TABLE</command> method requires an
614+
<literal>ACCESS EXCLUSIVE</literal> lock on the table,
614615
but does not result in bloating the table with old row versions.
615616
</para>
616617

doc/src/sgml/indexam.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,10 @@ amparallelrescan (IndexScanDesc scan);
918918
<literal>RowExclusiveLock</literal> when updating the index (including plain
919919
<command>VACUUM</command>). Since these lock types do not conflict, the access
920920
method is responsible for handling any fine-grained locking it might need.
921-
An exclusive lock on the index as a whole will be taken only during index
922-
creation, destruction, or <command>REINDEX</command>.
921+
An <literal>ACCESS EXCLUSIVE</literal> lock on the index as a whole will be
922+
taken only during index creation, destruction, or <command>REINDEX</command>
923+
(<literal>SHARE UPDATE EXCLUSIVE</literal> is taken instead with
924+
<literal>CONCURRENTLY</literal>).
923925
</para>
924926

925927
<para>

doc/src/sgml/maintenance.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
<command>DELETE</command> will continue to function normally, though you
129129
will not be able to modify the definition of a table with commands such as
130130
<command>ALTER TABLE</command> while it is being vacuumed.)
131-
<command>VACUUM FULL</command> requires exclusive lock on the table it is
131+
<command>VACUUM FULL</command> requires an
132+
<literal>ACCESS EXCLUSIVE</literal> lock on the table it is
132133
working on, and therefore cannot be done in parallel with other use
133134
of the table. Generally, therefore,
134135
administrators should strive to use standard <command>VACUUM</command> and
@@ -231,7 +232,8 @@
231232
or one of the table-rewriting variants of
232233
<xref linkend="sql-altertable"/>.
233234
These commands rewrite an entire new copy of the table and build
234-
new indexes for it. All these options require exclusive lock. Note that
235+
new indexes for it. All these options require an
236+
<literal>ACCESS EXCLUSIVE</literal> lock. Note that
235237
they also temporarily use extra disk space approximately equal to the size
236238
of the table, since the old copies of the table and indexes can't be
237239
released until the new ones are complete.

doc/src/sgml/mvcc.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ ERROR: could not serialize access due to read/write dependencies among transact
826826
tables are not dropped or modified in incompatible ways while the
827827
command executes. (For example, <command>TRUNCATE</command> cannot safely be
828828
executed concurrently with other operations on the same table, so it
829-
obtains an exclusive lock on the table to enforce that.)
829+
obtains an <literal>ACCESS EXCLUSIVE</literal> lock on the table to
830+
enforce that.)
830831
</para>
831832

832833
<para>

doc/src/sgml/pgrowlocks.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ pgrowlocks(text) returns setof record
9797
<orderedlist>
9898
<listitem>
9999
<para>
100-
If the table as a whole is exclusive-locked by someone else,
101-
<function>pgrowlocks</function> will be blocked.
100+
If an <literal>ACCESS EXCLUSIVE</literal> lock is taken on the table,
101+
<function>pgrowlocks</function> will be blocked.
102102
</para>
103103
</listitem>
104104
<listitem>

doc/src/sgml/ref/drop_index.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] <replaceable class="parameter">name</r
4545
<para>
4646
Drop the index without locking out concurrent selects, inserts, updates,
4747
and deletes on the index's table. A normal <command>DROP INDEX</command>
48-
acquires an exclusive lock on the table, blocking other accesses until the
49-
index drop can be completed. With this option, the command instead
50-
waits until conflicting transactions have completed.
48+
acquires an <literal>ACCESS EXCLUSIVE</literal> lock on the table,
49+
blocking other accesses until the index drop can be completed. With
50+
this option, the command instead waits until conflicting transactions
51+
have completed.
5152
</para>
5253
<para>
5354
There are several caveats to be aware of when using this option.

doc/src/sgml/ref/reindex.sgml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,15 @@ REINDEX [ ( VERBOSE ) ] { INDEX | TABLE | SCHEMA | DATABASE | SYSTEM } [ CONCURR
232232
<command>REINDEX</command> is similar to a drop and recreate of the index
233233
in that the index contents are rebuilt from scratch. However, the locking
234234
considerations are rather different. <command>REINDEX</command> locks out writes
235-
but not reads of the index's parent table. It also takes an exclusive lock
236-
on the specific index being processed, which will block reads that attempt
237-
to use that index. In contrast, <command>DROP INDEX</command> momentarily takes
238-
an exclusive lock on the parent table, blocking both writes and reads. The
239-
subsequent <command>CREATE INDEX</command> locks out writes but not reads; since
240-
the index is not there, no read will attempt to use it, meaning that there
241-
will be no blocking but reads might be forced into expensive sequential
242-
scans.
235+
but not reads of the index's parent table. It also takes an
236+
<literal>ACCESS EXCLUSIVE</literal> lock on the specific index being processed,
237+
which will block reads that attempt to use that index. In contrast,
238+
<command>DROP INDEX</command> momentarily takes an
239+
<literal>ACCESS EXCLUSIVE</literal> lock on the parent table, blocking both
240+
writes and reads. The subsequent <command>CREATE INDEX</command> locks out
241+
writes but not reads; since the index is not there, no read will attempt to
242+
use it, meaning that there will be no blocking but reads might be forced
243+
into expensive sequential scans.
243244
</para>
244245

245246
<para>

doc/src/sgml/ref/vacuum.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ <replaceable class="paramet
7878
same table. <command>VACUUM FULL</command> rewrites the entire contents
7979
of the table into a new disk file with no extra space, allowing unused
8080
space to be returned to the operating system. This form is much slower and
81-
requires an exclusive lock on each table while it is being processed.
81+
requires an <literal>ACCESS EXCLUSIVE</literal> lock on each table while
82+
it is being processed.
8283
</para>
8384

8485
<para>

0 commit comments

Comments
 (0)