doc: Clarify use of ACCESS EXCLUSIVE lock in various sections
authorMichael Paquier <[email protected]>
Thu, 1 Apr 2021 06:28:37 +0000 (15:28 +0900)
committerMichael Paquier <[email protected]>
Thu, 1 Apr 2021 06:28:37 +0000 (15:28 +0900)
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

doc/src/sgml/ddl.sgml
doc/src/sgml/hstore.sgml
doc/src/sgml/indexam.sgml
doc/src/sgml/maintenance.sgml
doc/src/sgml/mvcc.sgml
doc/src/sgml/pgrowlocks.sgml
doc/src/sgml/ref/drop_index.sgml
doc/src/sgml/ref/reindex.sgml
doc/src/sgml/ref/vacuum.sgml

index 4a506bd6f008d75c6dbfdd58d6f58a3c4d44fdc7..30e417096345135cabcec70a03215d6b3f5b19e1 100644 (file)
@@ -2630,7 +2630,8 @@ SELECT * FROM information WHERE group_id = 2 FOR UPDATE;
    definer function.)  Also, heavy concurrent use of row share locks on the
    referenced table could pose a performance problem, especially if updates
    of it are frequent.  Another solution, practical if updates of the
-   referenced table are infrequent, is to take an exclusive lock on the
+   referenced table are infrequent, is to take an
+   <literal>ACCESS EXCLUSIVE</literal> lock on the
    referenced table when updating it, so that no concurrent transactions
    could be examining old row values.  Or one could just wait for all
    concurrent transactions to end after committing an update of the
index db5779052a564c80802313e09d3fad4f25a956ac..870063c288baab3d2ee91560be997aeb3448bb5b 100644 (file)
@@ -926,7 +926,8 @@ UPDATE tablename SET hstorecol = hstorecol || '';
 <programlisting>
 ALTER TABLE tablename ALTER hstorecol TYPE hstore USING hstorecol || '';
 </programlisting>
-   The <command>ALTER TABLE</command> method requires an exclusive lock on the table,
+   The <command>ALTER TABLE</command> method requires an
+   <literal>ACCESS EXCLUSIVE</literal> lock on the table,
    but does not result in bloating the table with old row versions.
   </para>
 
index ec5741df6d16414691565a93a959978e4b14b04b..29fa3b793381bfa358cbc5cb7354fcb8c738c3b9 100644 (file)
@@ -980,8 +980,10 @@ amparallelrescan (IndexScanDesc scan);
    <literal>RowExclusiveLock</literal> when updating the index (including plain
    <command>VACUUM</command>).  Since these lock types do not conflict, the access
    method is responsible for handling any fine-grained locking it might need.
-   An exclusive lock on the index as a whole will be taken only during index
-   creation, destruction, or <command>REINDEX</command>.
+   An <literal>ACCESS EXCLUSIVE</literal> lock on the index as a whole will be
+   taken only during index creation, destruction, or <command>REINDEX</command>
+   (<literal>SHARE UPDATE EXCLUSIVE</literal> is taken instead with
+   <literal>CONCURRENTLY</literal>).
   </para>
 
   <para>
index 4d8ad754f8577ab74eb7d2ef9f258a423bca80ef..3bbae6dd917aa0d1bafd4b9487644b9639969715 100644 (file)
     <command>DELETE</command> will continue to function normally, though you
     will not be able to modify the definition of a table with commands such as
     <command>ALTER TABLE</command> while it is being vacuumed.)
-    <command>VACUUM FULL</command> requires exclusive lock on the table it is
+    <command>VACUUM FULL</command> requires an
+    <literal>ACCESS EXCLUSIVE</literal> lock on the table it is
     working on, and therefore cannot be done in parallel with other use
     of the table.  Generally, therefore,
     administrators should strive to use standard <command>VACUUM</command> and
     or one of the table-rewriting variants of
     <link linkend="sql-altertable"><command>ALTER TABLE</command></link>.
     These commands rewrite an entire new copy of the table and build
-    new indexes for it.  All these options require exclusive lock.  Note that
+    new indexes for it.  All these options require an
+    <literal>ACCESS EXCLUSIVE</literal> lock.  Note that
     they also temporarily use extra disk space approximately equal to the size
     of the table, since the old copies of the table and indexes can't be
     released until the new ones are complete.
index 71dd4033372d5a36346bfe1ad82bb45d72192058..b46cba8158285fe348246421c801a16ffe07dc11 100644 (file)
@@ -826,7 +826,8 @@ ERROR:  could not serialize access due to read/write dependencies among transact
     tables are not dropped or modified in incompatible ways while the
     command executes.  (For example, <command>TRUNCATE</command> cannot safely be
     executed concurrently with other operations on the same table, so it
-    obtains an exclusive lock on the table to enforce that.)
+    obtains an <literal>ACCESS EXCLUSIVE</literal> lock on the table to
+    enforce that.)
    </para>
 
    <para>
index 60e13393ea6208f20b5285f58c8fc342ad642042..392d5f1f9a773368a3eef5f3a664aaefe1a53dcd 100644 (file)
@@ -97,8 +97,8 @@ pgrowlocks(text) returns setof record
   <orderedlist>
    <listitem>
     <para>
-    If the table as a whole is exclusive-locked by someone else,
-    <function>pgrowlocks</function> will be blocked.
+     If an <literal>ACCESS EXCLUSIVE</literal> lock is taken on the table,
+     <function>pgrowlocks</function> will be blocked.
     </para>
    </listitem>
    <listitem>
index b6d2c2014f28e82d6f69aa41e4eb9fb0b931a4c4..aabc85e2300201f4e747694a9b152ffb6430c932 100644 (file)
@@ -45,9 +45,10 @@ DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] <replaceable class="parameter">name</r
      <para>
       Drop the index without locking out concurrent selects, inserts, updates,
       and deletes on the index's table.  A normal <command>DROP INDEX</command>
-      acquires an exclusive lock on the table, blocking other accesses until the
-      index drop can be completed.  With this option, the command instead
-      waits until conflicting transactions have completed.
+      acquires an <literal>ACCESS EXCLUSIVE</literal> lock on the table,
+      blocking other accesses until the index drop can be completed.  With
+      this option, the command instead waits until conflicting transactions
+      have completed.
      </para>
      <para>
       There are several caveats to be aware of when using this option.
index ff4dba8c3631b48e52d12e8bc630fcfe527ab998..5875ecb93f789a0335946e61d69cfa55771a23f1 100644 (file)
@@ -282,14 +282,15 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { IN
    <command>REINDEX</command> is similar to a drop and recreate of the index
    in that the index contents are rebuilt from scratch.  However, the locking
    considerations are rather different.  <command>REINDEX</command> locks out writes
-   but not reads of the index's parent table.  It also takes an exclusive lock
-   on the specific index being processed, which will block reads that attempt
-   to use that index.  In contrast, <command>DROP INDEX</command> momentarily takes
-   an exclusive lock on the parent table, blocking both writes and reads.  The
-   subsequent <command>CREATE INDEX</command> locks out writes but not reads; since
-   the index is not there, no read will attempt to use it, meaning that there
-   will be no blocking but reads might be forced into expensive sequential
-   scans.
+   but not reads of the index's parent table.  It also takes an
+   <literal>ACCESS EXCLUSIVE</literal> lock on the specific index being processed,
+   which will block reads that attempt to use that index.  In contrast,
+   <command>DROP INDEX</command> momentarily takes an
+   <literal>ACCESS EXCLUSIVE</literal> lock on the parent table, blocking both
+   writes and reads.  The subsequent <command>CREATE INDEX</command> locks out
+   writes but not reads; since the index is not there, no read will attempt to
+   use it, meaning that there will be no blocking but reads might be forced
+   into expensive sequential scans.
   </para>
 
   <para>
index bb1c0f8fb6f1c27271f37565386ad67fd68b7c57..6a0028a514252418a00ac9a21d495011e666ed93 100644 (file)
@@ -83,8 +83,8 @@ VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ <replaceable class="paramet
    specify parallel workers as zero.  <command>VACUUM FULL</command> rewrites
    the entire contents of the table into a new disk file with no extra space,
    allowing unused space to be returned to the operating system.  This form is
-   much slower and requires an exclusive lock on each table while it is being
-   processed.
+   much slower and requires an <literal>ACCESS EXCLUSIVE</literal> lock on
+   each table while it is being processed.
   </para>
 
   <para>