Re: "ERROR: could not open relation with OID 16391" error was encountered when reindexing

From: feichanghong <feichanghong(at)qq(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: "ERROR: could not open relation with OID 16391" error was encountered when reindexing
Date: 2024-01-16 16:54:26
Message-ID: tencent_88130E040451A5E577960CA4CED70F281307@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> This is extremely nonspecific, as line numbers in our code change
> constantly. Please quote a chunk of code surrounding that
> and indicate which line you are trying to stop at.

Thanks for the suggestion, I've refined the steps below to reproduce:
1. Initialize the data
```
DROP TABLE IF EXISTS tbl_part;
CREATE TABLE tbl_part (a integer) PARTITION BY RANGE (a);
CREATE TABLE tbl_part_p1 PARTITION OF tbl_part FOR VALUES FROM (0) TO (10);
CREATE INDEX ON tbl_part(a);
```
2. session1 reindex and the gdb break after the reindex_index function successfully obtains the heapId, as noted in the code chunk below:

reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
const ReindexParams *params)
{
......
/*
* Open and lock the parent heap relation. ShareLock is sufficient since
* we only need to be sure no schema or data changes are going on.
*/
heapId = IndexGetRelation(indexId,
(params->options & REINDEXOPT_MISSING_OK) != 0);
====> gdb break at here
/* if relation is missing, leave */
if (!OidIsValid(heapId))
return;
```
REINDEX INDEX tbl_part_a_idx;
```
3. session2 drop index succeed

```
DROP INDEX tbl_part_a_idx;
```
4. session1 gdb continue

Best Regards,
Fei Changhong
Alibaba Cloud Computing Ltd.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-01-16 17:06:43 Re: ALTER TYPE OWNER fails to recurse to multirange
Previous Message Andrew Dunstan 2024-01-16 16:49:52 Re: psql JSON output format