mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
In the new dispensation where REINDEX doesn't take exclusive lock on
the parent table, it's essential that all index accesses take some kind of lock on the index. I had missed vacuumlazy.c :-( ...
This commit is contained in:
@ -31,7 +31,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.47 2004/10/15 22:39:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.48 2004/10/25 15:42:02 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -554,9 +554,12 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
|
|||||||
vac_init_rusage(&ru0);
|
vac_init_rusage(&ru0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If index is unsafe for concurrent access, must lock it.
|
* Acquire appropriate type of lock on index: must be exclusive if
|
||||||
|
* index AM isn't concurrent-safe.
|
||||||
*/
|
*/
|
||||||
if (!indrel->rd_am->amconcurrent)
|
if (indrel->rd_am->amconcurrent)
|
||||||
|
LockRelation(indrel, RowExclusiveLock);
|
||||||
|
else
|
||||||
LockRelation(indrel, AccessExclusiveLock);
|
LockRelation(indrel, AccessExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -576,7 +579,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
|
|||||||
/*
|
/*
|
||||||
* Release lock acquired above.
|
* Release lock acquired above.
|
||||||
*/
|
*/
|
||||||
if (!indrel->rd_am->amconcurrent)
|
if (indrel->rd_am->amconcurrent)
|
||||||
|
UnlockRelation(indrel, RowExclusiveLock);
|
||||||
|
else
|
||||||
UnlockRelation(indrel, AccessExclusiveLock);
|
UnlockRelation(indrel, AccessExclusiveLock);
|
||||||
|
|
||||||
if (!stats)
|
if (!stats)
|
||||||
@ -619,9 +624,12 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats)
|
|||||||
vac_init_rusage(&ru0);
|
vac_init_rusage(&ru0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If index is unsafe for concurrent access, must lock it.
|
* Acquire appropriate type of lock on index: must be exclusive if
|
||||||
|
* index AM isn't concurrent-safe.
|
||||||
*/
|
*/
|
||||||
if (!indrel->rd_am->amconcurrent)
|
if (indrel->rd_am->amconcurrent)
|
||||||
|
LockRelation(indrel, RowExclusiveLock);
|
||||||
|
else
|
||||||
LockRelation(indrel, AccessExclusiveLock);
|
LockRelation(indrel, AccessExclusiveLock);
|
||||||
|
|
||||||
/* Do bulk deletion */
|
/* Do bulk deletion */
|
||||||
@ -636,7 +644,9 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats)
|
|||||||
/*
|
/*
|
||||||
* Release lock acquired above.
|
* Release lock acquired above.
|
||||||
*/
|
*/
|
||||||
if (!indrel->rd_am->amconcurrent)
|
if (indrel->rd_am->amconcurrent)
|
||||||
|
UnlockRelation(indrel, RowExclusiveLock);
|
||||||
|
else
|
||||||
UnlockRelation(indrel, AccessExclusiveLock);
|
UnlockRelation(indrel, AccessExclusiveLock);
|
||||||
|
|
||||||
if (!stats)
|
if (!stats)
|
||||||
|
Reference in New Issue
Block a user