Commit fcb4bfdd authored by Simon Riggs's avatar Simon Riggs

Reduce lock level for altering fillfactor

Fabrízio de Royes Mello and Simon Riggs
parent 090b287f
......@@ -561,7 +561,7 @@ ALTER TABLE ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable>
</para>
<para>
Changing autovacuum storage parameters acquires a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
Changing fillfactor and autovacuum storage parameters acquires a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
</para>
<note>
......
......@@ -100,7 +100,7 @@ static relopt_int intRelOpts[] =
"fillfactor",
"Packs table pages only to this percentage",
RELOPT_KIND_HEAP,
AccessExclusiveLock
ShareUpdateExclusiveLock /* since it applies only to later inserts */
},
HEAP_DEFAULT_FILLFACTOR, HEAP_MIN_FILLFACTOR, 100
},
......@@ -109,7 +109,7 @@ static relopt_int intRelOpts[] =
"fillfactor",
"Packs btree index pages only to this percentage",
RELOPT_KIND_BTREE,
AccessExclusiveLock
ShareUpdateExclusiveLock /* since it applies only to later inserts */
},
BTREE_DEFAULT_FILLFACTOR, BTREE_MIN_FILLFACTOR, 100
},
......@@ -118,7 +118,7 @@ static relopt_int intRelOpts[] =
"fillfactor",
"Packs hash index pages only to this percentage",
RELOPT_KIND_HASH,
AccessExclusiveLock
ShareUpdateExclusiveLock /* since it applies only to later inserts */
},
HASH_DEFAULT_FILLFACTOR, HASH_MIN_FILLFACTOR, 100
},
......@@ -127,7 +127,7 @@ static relopt_int intRelOpts[] =
"fillfactor",
"Packs gist index pages only to this percentage",
RELOPT_KIND_GIST,
AccessExclusiveLock
ShareUpdateExclusiveLock /* since it applies only to later inserts */
},
GIST_DEFAULT_FILLFACTOR, GIST_MIN_FILLFACTOR, 100
},
......@@ -136,7 +136,7 @@ static relopt_int intRelOpts[] =
"fillfactor",
"Packs spgist index pages only to this percentage",
RELOPT_KIND_SPGIST,
AccessExclusiveLock
ShareUpdateExclusiveLock /* since it applies only to later inserts */
},
SPGIST_DEFAULT_FILLFACTOR, SPGIST_MIN_FILLFACTOR, 100
},
......
......@@ -2065,19 +2065,19 @@ select * from my_locks order by 1;
commit;
begin; alter table alterlock set (fillfactor = 100);
select * from my_locks order by 1;
relname | max_lockmode
-----------+---------------------
alterlock | AccessExclusiveLock
pg_toast | AccessExclusiveLock
relname | max_lockmode
-----------+--------------------------
alterlock | ShareUpdateExclusiveLock
pg_toast | ShareUpdateExclusiveLock
(2 rows)
commit;
begin; alter table alterlock reset (fillfactor);
select * from my_locks order by 1;
relname | max_lockmode
-----------+---------------------
alterlock | AccessExclusiveLock
pg_toast | AccessExclusiveLock
relname | max_lockmode
-----------+--------------------------
alterlock | ShareUpdateExclusiveLock
pg_toast | ShareUpdateExclusiveLock
(2 rows)
commit;
......@@ -2110,10 +2110,10 @@ rollback;
-- test that mixing options with different lock levels works as expected
begin; alter table alterlock set (autovacuum_enabled = off, fillfactor = 80);
select * from my_locks order by 1;
relname | max_lockmode
-----------+---------------------
alterlock | AccessExclusiveLock
pg_toast | AccessExclusiveLock
relname | max_lockmode
-----------+--------------------------
alterlock | ShareUpdateExclusiveLock
pg_toast | ShareUpdateExclusiveLock
(2 rows)
commit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment