reindexing an invalid index should not use ERRCODE_INDEX_CORRUPTED - Mailing list pgsql-hackers

From Andres Freund
Subject reindexing an invalid index should not use ERRCODE_INDEX_CORRUPTED
Date
Msg-id 20231118230958.4fm3fhk4ypshxopa@awork3.anarazel.de
Whole thread Raw
Responses Re: reindexing an invalid index should not use ERRCODE_INDEX_CORRUPTED
List 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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: errcode_for_file_access() maps EROFS to INSUFFICIENT_PRIVILEGE
Next
From: Alena Rybakina
Date:
Subject: Re: [PoC] Reducing planning time when tables have many partitions