PG upgrade might fail due to missing `pg_depend` records for columnar tables (v10.0.x & v10.1.x)
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
edited by @onurctirtir: For the workaround, see https://github.com/citusdata/citus/pull/5456#issuecomment-971429595.
-----
We have seen with a customer that there was an error similar to this one when doing a pg upgrade:
```
pg_restore: error: could not execute query: ERROR: could not open relation with OID 0
Command was:
-- For binary upgrade, must preserve pg_type oid
SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('17095'::pg_catalog.oid);
-- For binary upgrade, must preserve pg_type array oid
SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('17094'::pg_catalog.oid);
```
pg_upgrade didn't have much information but when setting `backtrace_functions` get a backtrace for the error we got:
```
ALTER system set backtrace_functions="relation_open";
SELECT pg_reload_conf();
postgres: postgres citus [local] CREATE TABLE() [0x49de75]
postgres: postgres citus [local] CREATE TABLE() [0x5f7813]
postgres: postgres citus [local] CREATE TABLE(nextval_internal+0x37) [0x5f86e7]
/usr/pgsql-14/lib/citus.so(+0xfdf7c) [0x7f64d9cdcf7c]
postgres: postgres citus [local] CREATE TABLE(heap_create+0x297) [0x546517]
postgres: postgres citus [local] CREATE TABLE(heap_create_with_catalog+0x233) [0x5480b3]
postgres: postgres citus [local] CREATE TABLE(DefineRelation+0x1912) [0x60acb2]
postgres: postgres citus [local] CREATE TABLE() [0x7bc188]
postgres: postgres citus [local] CREATE TABLE(standard_ProcessUtility+0x211) [0x7ba881]
/usr/pgsql-14/lib/citus.so(multi_ProcessUtility+0x207) [0x7f64d9c4fbc7]
/usr/pgsql-14/lib/pg_stat_statements.so(+0x4df3) [0x7f64d8537df3]
postgres: postgres citus [local] CREATE TABLE() [0x7b909a]
postgres: postgres citus [local] CREATE TABLE() [0x7b91a9]
postgres: postgres citus [local] CREATE TABLE(PortalRun+0x179) [0x7b9609]
postgres: postgres citus [local] CREATE TABLE() [0x7b54d7]
postgres: postgres citus [local] CREATE TABLE(PostgresMain+0x1153) [0x7b6953]
postgres: postgres citus [local] CREATE TABLE() [0x48d495]
postgres: postgres citus [local] CREATE TABLE(PostmasterMain+0xe72) [0x734102]
postgres: postgres citus [local] CREATE TABLE(main+0x6f2) [0x48e5b2]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7f64e618f555]
postgres: postgres citus [local] CREATE TABLE() [0x48e619]
```
even though the backtrace isn't very nice, it gives the call to `nextval_internal`:
```c
ColumnarMetadataNewStorageId()
{
return nextval_internal(ColumnarStorageIdSequenceRelationId(), false);
}
static Oid
ColumnarStorageIdSequenceRelationId(void)
{
return get_relname_relid("storageid_seq", ColumnarNamespaceId());
}
```
so it seems like `storageid_seq` not being created would give us the above error and looking at pg_dump it seemed like the creation of `storageid_seq` was after the creating of a columnar table hence the creation of a columnar table erroring out makes sense. (This still needs verification but I am just noting so that we don't forget)
Contributor guide
Assessment
This issue has not been assessed yet.