Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f70560

Browse files
Reset ALTER TABLE lock levels to AccessExclusiveLock in all cases.
Locks on inheritance parent remain at lower level, as they were before.Remove entry from 9.1 release notes.
1 parent3569e02 commit1f70560

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

‎doc/src/sgml/release-9.1.sgml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,7 @@
846846

847847
<listitem>
848848
<para>
849-
Add functions to control streaming replication replay (Simon
850-
Riggs)
849+
Add functions to control streaming replication replay (Simon Riggs)
851850
</para>
852851

853852
<para>
@@ -1742,20 +1741,6 @@
17421741
</para>
17431742
</listitem>
17441743

1745-
<listitem>
1746-
<para>
1747-
Minimize lock levels for <link
1748-
linkend="SQL-CREATETRIGGER"><command>CREATE TRIGGER</></link>
1749-
and many <link linkend="SQL-ALTERTABLE"><command>ALTER
1750-
TABLE</></link> and <link linkend="SQL-CREATERULE"><command>CREATE
1751-
RULE</></link> operations (Simon Riggs)
1752-
</para>
1753-
1754-
<para>
1755-
This improves database availability when altering active databases.
1756-
</para>
1757-
</listitem>
1758-
17591744
</itemizedlist>
17601745

17611746
</sect4>

‎src/backend/commands/tablecmds.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,6 +2573,31 @@ AlterTableInternal(Oid relid, List *cmds, bool recurse)
25732573
LOCKMODE
25742574
AlterTableGetLockLevel(List*cmds)
25752575
{
2576+
/*
2577+
* Late in 9.1 dev cycle a number of issues were uncovered with access
2578+
* to catalog relations, leading to the decision to re-enforce all DDL
2579+
* at AccessExclusiveLock level by default.
2580+
*
2581+
* The issues are that there is a pervasive assumption in the code that
2582+
* the catalogs will not be read unless an AccessExclusiveLock is held.
2583+
* If that rule is relaxed, we must protect against a number of potential
2584+
* effects - infrequent, but proven possible with test cases where
2585+
* multiple DDL operations occur in a stream against frequently accessed
2586+
* tables.
2587+
*
2588+
* 1. Catalog tables are read using SnapshotNow, which has a race bug
2589+
* that allows a scan to return no valid rows even when one is present
2590+
* in the case of a commit of a concurrent update of the catalog table.
2591+
* SnapshotNow also ignores transactions in progress, so takes the
2592+
* latest committed version without waiting for the latest changes.
2593+
*
2594+
* 2. Relcache needs to be internally consistent, so unless we lock the
2595+
* definition during reads we have no way to guarantee that.
2596+
*
2597+
* 3. Catcache access isn't coordinated at all so refreshes can occur at
2598+
* any time.
2599+
*/
2600+
#ifdefREDUCED_ALTER_TABLE_LOCK_LEVELS
25762601
ListCell*lcmd;
25772602
LOCKMODElockmode=ShareUpdateExclusiveLock;
25782603

@@ -2721,6 +2746,9 @@ AlterTableGetLockLevel(List *cmds)
27212746
if (cmd_lockmode>lockmode)
27222747
lockmode=cmd_lockmode;
27232748
}
2749+
#else
2750+
LOCKMODElockmode=AccessExclusiveLock;
2751+
#endif
27242752

27252753
returnlockmode;
27262754
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp