Skip to content

Commit a95307b

Browse files
committed
Teach reindex_index() to clear pg_index.indcheckxmin when possible.
Greg Stark, slightly modified by me.
1 parent c1dcaa8 commit a95307b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/backend/catalog/index.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.313 2009/03/24 20:17:12 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.314 2009/03/27 15:57:11 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -2243,6 +2243,7 @@ reindex_index(Oid indexId)
22432243
pg_index;
22442244
Oid heapId;
22452245
bool inplace;
2246+
IndexInfo *indexInfo;
22462247
HeapTuple indexTuple;
22472248
Form_pg_index indexForm;
22482249

@@ -2293,8 +2294,6 @@ reindex_index(Oid indexId)
22932294

22942295
PG_TRY();
22952296
{
2296-
IndexInfo *indexInfo;
2297-
22982297
/* Suppress use of the target index while rebuilding it */
22992298
SetReindexProcessing(heapId, indexId);
23002299

@@ -2333,6 +2332,10 @@ reindex_index(Oid indexId)
23332332
* If the index is marked invalid or not ready (ie, it's from a failed
23342333
* CREATE INDEX CONCURRENTLY), we can now mark it valid. This allows
23352334
* REINDEX to be used to clean up in such cases.
2335+
*
2336+
* We can also reset indcheckxmin, because we have now done a
2337+
* non-concurrent index build, *except* in the case where index_build
2338+
* found some still-broken HOT chains.
23362339
*/
23372340
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
23382341

@@ -2343,10 +2346,13 @@ reindex_index(Oid indexId)
23432346
elog(ERROR, "cache lookup failed for index %u", indexId);
23442347
indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
23452348

2346-
if (!indexForm->indisvalid || !indexForm->indisready)
2349+
if (!indexForm->indisvalid || !indexForm->indisready ||
2350+
(indexForm->indcheckxmin && !indexInfo->ii_BrokenHotChain))
23472351
{
23482352
indexForm->indisvalid = true;
23492353
indexForm->indisready = true;
2354+
if (!indexInfo->ii_BrokenHotChain)
2355+
indexForm->indcheckxmin = false;
23502356
simple_heap_update(pg_index, &indexTuple->t_self, indexTuple);
23512357
CatalogUpdateIndexes(pg_index, indexTuple);
23522358
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy