Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error during upgrade to 2.2.1 #3331

Closed
fvannee opened this issue Jun 14, 2021 · 2 comments · Fixed by #3336
Closed

error during upgrade to 2.2.1 #3331

fvannee opened this issue Jun 14, 2021 · 2 comments · Fixed by #3336
Assignees
Labels

Comments

@fvannee
Copy link
Contributor

fvannee commented Jun 14, 2021

Relevant system information:

  • OS: CentOS
  • PostgreSQL version (output of postgres --version): 12
  • TimescaleDB version (output of \dx in psql): 1.7.3 -> 2.2.1 upgrade
  • Installation method: source

Describe the bug
When upgrading timescaledb, I ran into the following error:

db=# alter extension timescaledb update;
ERROR:  duplicate key value violates unique constraint "saved_privs_tmpnsp_tmpname_key"
DETAIL:  Key (tmpnsp, tmpname)=(_timescaledb_catalog, chunk_constraint_name) already exists.

During the pre-upgrade phase, TSDB saves the pg_init_privs temporarily into a table, with the following SQL.

-- Table for ACL and initprivs of tables. 
CREATE TABLE saved_privs(
       tmpnsp name,
       tmpname name,
       tmpacl aclitem[],
       tmpini aclitem[],
       UNIQUE (tmpnsp, tmpname));

-- We save away both the ACL and the initprivs for all tables and
-- views in the extension (but not for chunks and internal objects) so
-- that we can restore them to the proper state after the update.
INSERT INTO saved_privs
SELECT nspname, relname, relacl, initprivs
  FROM pg_class cl JOIN pg_namespace ns ON ns.oid = relnamespace
                   JOIN pg_init_privs ip ON ip.objoid = cl.oid
WHERE nspname IN ('_timescaledb_catalog', '_timescaledb_config')
   OR nspname = '_timescaledb_internal'
  AND relname IN ('hypertable_chunk_local_size', 'compressed_chunk_stats',
                  'bgw_job_stat', 'bgw_policy_chunk_stats');

The UNIQUE constraint of this table was validated. Indeed, when looking into the catalog, I found multiple rows in pg_init_privs for the same (tmpnsp, tmpname).
I "fixed" it manually by removing one row from the pg_init_privs table so that it was unique again, and then I ran the upgrade. But I wonder why the upgrade script does not support multiple rows here. At first, I was going to do dismiss it as some strange one-off, but I've encountered this twice now during an upgrade. I'm not sure under what circumstances this occurs exactly though.

@mglonnro
Copy link

I had the same thing happening to me with slightly different parameters:

  • OS: Debian
  • PostgreSQL 13 (but during this process upgraded from 11 to 13)
  • TimescaleDB: attempted upgrade from 2.1.1 to 2.3.0
  • Installation method: apt-get
charlotte=# ALTER EXTENSION timescaledb UPDATE;
ERROR:  duplicate key value violates unique constraint "saved_privs_tmpnsp_tmpname_key"
DETAIL:  Key (tmpnsp, tmpname)=(_timescaledb_catalog, dimension) already exists.

@ebreijo
Copy link

ebreijo commented Jun 15, 2021

I'm having the same issue when trying to update from 2.1.0 to 2.3.0 on Postgres 13

psql --host=localhost --port=5432 --username=postgres --password --dbname=kyoto --no-psqlrc --command="ALTER EXTENSION timescaledb UPDATE;"
ERROR:  duplicate key value violates unique constraint "saved_privs_tmpnsp_tmpname_key"
DETAIL:  Key (tmpnsp, tmpname)=(_timescaledb_catalog, dimension_slice) already exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants