citusdata / citusdata/pg_intpair

pg_dump issues

Open
#2 2 comments 0 reactions 1 assignee Claimed by @pykello View on GitHub
Dominant language
C
Stars
7
Forks
4
PR merge metrics
No merged PRs in 30d

Description

I'm hitting an issue with pg_upgrade (probably specifically pg_dump) interacting poorly with the pg_intpair extension from Citus. Specifically, when upgrading a db with intpair from PG9.5 to PG10, it seems that function dependencies are not respected, causing recreation of some functions to fail.

Note that we are using a fork of pg_intpair that renames the type to app_user_id. However, earlier testing showed that this problem affects both versions.

In the extension, we define the `btree_app_user_id_ops` (https://github.com/heap/pg_intpair/blob/master/intpair--0.1.sql#L121) operator class, which depends on the `app_user_id < app_user_id` operator (https://github.com/heap/pg_intpair/blob/master/intpair--0.1.sql#L66). This means that `<` must be defined before `btree_app_user_id_ops`.

However, when running pg_restore step in pg_upgrade, it seems to attempt to define `btree_app_user_id_ops` before defining `<`. (logs below)

Is there any way to make this dependency be respected? Is there any way to fix the extension? Removing the intpair extension before upgrading is hard because we have tables and indexes depending on it, so we would prefer to avoid doing it.

```
command: "/usr/lib/postgresql/10/bin/pg_restore" --host /data/pg_upgrade_logs --port 50432 --username heap --exit-on-error --verbose --dbname 'dbname=postgres' "pg_upgrade_dump_12379.custom" >> "pg_upgrade_dump_12379.log" 2>&1
pg_restore: connecting to database for restore
pg_restore: creating pg_largeobject "pg_largeobject"
pg_restore: creating pg_largeobject_metadata "pg_largeobject_metadata"
pg_restore: creating COMMENT "DATABASE "postgres""
pg_restore: creating EXTENSION "citus"
pg_restore: creating COMMENT "EXTENSION "citus""
pg_restore: creating SCHEMA "citus"
pg_restore: creating SCHEMA "public"
pg_restore: creating COMMENT "SCHEMA "public""
pg_restore: creating EXTENSION "btree_gist"
pg_restore: creating COMMENT "EXTENSION "btree_gist""
pg_restore: creating EXTENSION "dblink"
pg_restore: creating COMMENT "EXTENSION "dblink""
pg_restore: creating EXTENSION "hll"
pg_restore: creating COMMENT "EXTENSION "hll""
pg_restore: creating EXTENSION "hstore"
pg_restore: creating COMMENT "EXTENSION "hstore""
pg_restore: creating EXTENSION "intpair"
pg_restore: creating EXTENSION "json_build"
pg_restore: creating COMMENT "EXTENSION "json_build""
pg_restore: creating EXTENSION "session_analytics"
pg_restore: creating TYPE "citus.colocation_placement_type"
pg_restore: creating TYPE "citus.distribution_type"
pg_restore: creating SHELL TYPE "public.app_user_id"
pg_restore: creating FUNCTION "public.app_user_id_in("cstring")"
pg_restore: creating FUNCTION "public.app_user_id_out("public"."app_user_id")"
pg_restore: creating TYPE "public.app_user_id"
pg_restore: creating TYPE "public.app_user_id_old"
pg_restore: creating TYPE "public.app_user_id_old_range"
pg_restore: creating OPERATOR FAMILY "public.btree_app_user_id_ops"
pg_restore: creating OPERATOR CLASS "public.btree_app_user_id_ops"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3724; 2616 1937644986 OPERATOR CLASS btree_app_user_id_ops heap
pg_restore: [archiver (db)] could not execute query: ERROR: operator does not exist: public.app_user_id public.< public.app_user_id
Command was: CREATE OPERATOR CLASS "public"."btree_app_user_id_ops"
DEFAULT FOR TYPE "public"."app_user_id" USING "btree" FAMILY "public"."btree_app_user_id_ops" AS
OPERATOR 1 "public".<("public"."app_user_id","public"."app_user_id") ,
OPERATOR 2 "public".<=("public"."app_user_id","public"."app_user_id") ,
OPERATOR 3 "public".=("public"."app_user_id","public"."app_user_id") ,
OPERATOR 4 "public".>=("public"."app_user_id","public"."app_user_id") ,
OPERATOR 5 "public".>("public"."app_user_id","public"."app_user_id") ,
FUNCTION 1 ("public"."app_user_id", "public"."app_user_id") "public"."app_user_id_cmp"("public"."app_user_id","public"."app_user_id");
-- For binary upgrade, handle extension membership the hard way
ALTER EXTENSION "intpair" ADD OPERATOR CLASS "public"."btree_app_user_id_ops" USING "btree";
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.