reindexing an invalid index should not use ERRCODE_INDEX_CORRUPTED
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org, Michael Paquier <michael.paquier@gmail.com>, Peter Eisentraut <peter@eisentraut.org>
Date: 2023-11-18T23:09:58Z
Lists: pgsql-hackers
Hi,
We currently provide no way to learn about a postgres instance having
corruption than searching the logs for corruption events than matching by
sqlstate, for ERRCODE_DATA_CORRUPTED and ERRCODE_INDEX_CORRUPTED.
Unfortunately, there is a case of such an sqlstate that's not at all indicating
corruption, namely REINDEX CONCURRENTLY when the index is invalid:
if (!indexRelation->rd_index->indisvalid)
ereport(WARNING,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("cannot reindex invalid index \"%s.%s\" concurrently, skipping",
get_namespace_name(get_rel_namespace(cellOid)),
get_rel_name(cellOid))));
The only thing required to get to this is an interrupted CREATE INDEX
CONCURRENTLY, which I don't think can be fairly characterized as "corruption".
ISTM something like ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE would be more
appropriate?
Greetings,
Andres Freund
Commits
-
Improve some error messages with invalid indexes for REINDEX CONCURRENTLY
- d43bd090a8fe 17.0 landed