Skip to content

Commit 5ae0743

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 72ceeab commit 5ae0743

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

doc/src/sgml/ddl.sgml

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

doc/src/sgml/hstore.sgml

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

617618
</sect2>

doc/src/sgml/indexam.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,8 @@ amrestrpos (IndexScanDesc scan);
793793
<literal>RowExclusiveLock</> when updating the index (including plain
794794
<command>VACUUM</>). Since these lock types do not conflict, the access
795795
method is responsible for handling any fine-grained locking it might need.
796-
An exclusive lock on the index as a whole will be taken only during index
797-
creation, destruction, or <command>REINDEX</>.
796+
An <literal>ACCESS EXCLUSIVE</> lock on the index as a whole will be
797+
taken only during index creation, destruction, or <command>REINDEX</>.
798798
</para>
799799

800800
<para>

doc/src/sgml/maintenance.sgml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@
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</> requires exclusive lock on the table it is
132-
working on, and therefore cannot be done in parallel with other use
133-
of the table. Generally, therefore,
131+
<command>VACUUM FULL</> requires an <literal>ACCESS EXCLUSIVE</> lock
132+
on the table it is working on, and therefore cannot be done in parallel
133+
with other use of the table. Generally, therefore,
134134
administrators should strive to use standard <command>VACUUM</> and
135135
avoid <command>VACUUM FULL</>.
136136
</para>
@@ -231,7 +231,8 @@
231231
or one of the table-rewriting variants of
232232
<xref linkend="sql-altertable">.
233233
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
234+
new indexes for it. All these options require an
235+
<literal>ACCESS EXCLUSIVE</literal> lock. Note that
235236
they also temporarily use extra disk space approximately equal to the size
236237
of the table, since the old copies of the table and indexes can't be
237238
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
@@ -824,7 +824,8 @@ ERROR: could not serialize access due to read/write dependencies among transact
824824
tables are not dropped or modified in incompatible ways while the
825825
command executes. (For example, <command>TRUNCATE</> cannot safely be
826826
executed concurrently with other operations on the same table, so it
827-
obtains an exclusive lock on the table to enforce that.)
827+
obtains an <literal>ACCESS EXCLUSIVE</literal> lock on the table to
828+
enforce that.)
828829
</para>
829830

830831
<para>

doc/src/sgml/pgrowlocks.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ pgrowlocks(text) returns setof record
9090
<orderedlist>
9191
<listitem>
9292
<para>
93-
If the table as a whole is exclusive-locked by someone else,
94-
<function>pgrowlocks</function> will be blocked.
93+
If an <literal>ACCESS EXCLUSIVE</literal> lock is taken on the table,
94+
<function>pgrowlocks</function> will be blocked.
9595
</para>
9696
</listitem>
9797
<listitem>

doc/src/sgml/ref/drop_index.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ 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</>
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</> lock on the table, blocking
49+
other accesses until the index drop can be completed. With this option,
50+
the command instead waits until conflicting transactions have completed.
5151
</para>
5252
<para>
5353
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
@@ -213,14 +213,15 @@ REINDEX [ ( VERBOSE ) ] { INDEX | TABLE | SCHEMA | DATABASE | SYSTEM } <replacea
213213
<command>REINDEX</command> is similar to a drop and recreate of the index
214214
in that the index contents are rebuilt from scratch. However, the locking
215215
considerations are rather different. <command>REINDEX</> locks out writes
216-
but not reads of the index's parent table. It also takes an exclusive lock
217-
on the specific index being processed, which will block reads that attempt
218-
to use that index. In contrast, <command>DROP INDEX</> momentarily takes
219-
an exclusive lock on the parent table, blocking both writes and reads. The
220-
subsequent <command>CREATE INDEX</> locks out writes but not reads; since
221-
the index is not there, no read will attempt to use it, meaning that there
222-
will be no blocking but reads might be forced into expensive sequential
223-
scans.
216+
but not reads of the index's parent table. It also takes an
217+
<literal>ACCESS EXCLUSIVE</literal> lock on the specific index being processed,
218+
which will block reads that attempt to use that index. In contrast,
219+
<command>DROP INDEX</command> momentarily takes an
220+
<literal>ACCESS EXCLUSIVE</literal> lock on the parent table, blocking both
221+
writes and reads. The subsequent <command>CREATE INDEX</> locks out
222+
writes but not reads; since the index is not there, no read will attempt to
223+
use it, meaning that there will be no blocking but reads might be forced
224+
into expensive sequential scans.
224225
</para>
225226

226227
<para>

doc/src/sgml/ref/vacuum.sgml

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

6970
<para>

0 commit comments

Comments
 (0)