Pavel Stehule <pavel.stehule@gmail.com> writes:
> some customer has PostgreSQL 9.5.5. He cannot to login to database due
> broken index
> When I use single mode against to this database I got a error
> start transaction
> could not open critical system index 2679
I can't reproduce this. Removing file 2679 (pg_index_indexrelid_index)
from an otherwise-OK database leads to
$ postgres --single busted
FATAL: could not open file "base/78215/2679": No such file or directory
as expected, but
$ postgres --single -P busted
PostgreSQL stand-alone backend 9.5.15
backend>
and all seems well, in particular I can successfully do
backend> reindex index pg_index_indexrelid_index;
and then things are back to normal.
So either this is something we fixed since 9.5.5, or your summary
of the problem is missing many critical details.
I got different error message "could not open critical system index". I checked files, and related files was there.
I think so this issue is related to some damage of some system catalog - maybe pg_class, pg_attribute, ..
I got some diagnostics, but it is running on win, and the connect there is pretty slow
static void
load_critical_index(Oid indexoid, Oid heapoid)
{
<-->Relation<-->ird;
<-->/*
<--> * We must lock the underlying catalog before locking the index to avoid
<--> * deadlock, since RelationBuildDesc might well need to read the catalog,
<--> * and if anyone else is exclusive-locking this catalog and index they'll
<--> * be doing it in that order.
<--> */
<-->LockRelationOid(heapoid, AccessShareLock);
<-->LockRelationOid(indexoid, AccessShareLock);
<-->ird = RelationBuildDesc(indexoid, true);
<-->if (ird == NULL)
<--><-->elog(PANIC, "could not open critical system index %u", indexoid);
<-->ird->rd_isnailed = true;
<-->ird->rd_refcnt = 1;
<-->UnlockRelationOid(indexoid, AccessShareLock);
<-->UnlockRelationOid(heapoid, AccessShareLock);
looks like this code is called every time
Note:
I was not able to compile PostgreSQL 9.5 on Fedora 29 :-/
regards, tom lane