Skip to content
New issue

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

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

Already on GitHub? # to your account

pg: ensure all tables have full replica identity #1034

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

jchappelow
Copy link
Member

@jchappelow jchappelow commented Sep 27, 2024

resolves #1025

@jchappelow
Copy link
Member Author

jchappelow commented Sep 27, 2024

This is working now.

Starting with a kwildb-snapshot.sql.gz from v0.8, start with v0.9 in genesis_state using that file (genesis apphash "z0YcmAr5MDZHpgdRyWH4QAiKzMt0yZwb8lWEFr8Ji4A="):

v0.9 main

# \d+ ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.users
                  Table "ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.users"
  Column  |  Type  | Collation | Nullable |   Default   | Storage  | Compression | Stats target | Description 
----------+--------+-----------+----------+-------------+----------+-------------+--------------+-------------
 id       | bigint |           | not null |             | plain    |             |              | 
 username | text   |           |          | 'sds'::text | extended |             |              | 
 age      | bigint |           |          |             | plain    |             |              | 
 wallet   | text   |           |          |             | extended |             |              | 
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
    "users_wallet_key" UNIQUE CONSTRAINT, btree (wallet)
Check constraints:
    "users_age_check" CHECK (age >= 0)
Referenced by:
    TABLE "ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.posts" CONSTRAINT "posts_user_id_fkey" FOREIGN KEY (user_id) REFERENCES ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.users(id) ON UPDATE CASCADE ON DELETE CASCADE
Publications:
    "kwild_repl"
Access method: heap

v0.9 this PR

# \d+ ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.users
                  Table "ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.users"
  Column  |  Type  | Collation | Nullable |   Default   | Storage  | Compression | Stats target | Description 
----------+--------+-----------+----------+-------------+----------+-------------+--------------+-------------
 id       | bigint |           | not null |             | plain    |             |              | 
 username | text   |           |          | 'sds'::text | extended |             |              | 
 age      | bigint |           |          |             | plain    |             |              | 
 wallet   | text   |           |          |             | extended |             |              | 
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
    "users_wallet_key" UNIQUE CONSTRAINT, btree (wallet)
Check constraints:
    "users_age_check" CHECK (age >= 0)
Referenced by:
    TABLE "ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.posts" CONSTRAINT "posts_user_id_fkey" FOREIGN KEY (user_id) REFERENCES ds_x708dd55e1dda0fdcd727dc1813d941184622eb1223b1d744e8a49a2e.users(id) ON UPDATE CASCADE ON DELETE CASCADE
Publications:
    "kwild_repl"
Replica Identity: FULL
Access method: heap

It now has Replica Identity: FULL.

@@ -210,9 +210,6 @@ func newDBOpener(host, port, user, pass string) dbOpener {
},
MaxConns: maxConns,
},
SchemaFilter: func(s string) bool {
Copy link
Member Author

@jchappelow jchappelow Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When unset it defaults to what we were setting anyway. I've deprecated this field since there are numerous assumptions about "ds_", and if we set this field to any other function nothing would work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we should change it now, but is the "ds_" necessary? The original reason we prepended DBIDs with the "x" is so that they could be used as Postgres schemas (since Postgres schemas must start with a letter).

The only reason I bring it up is b/c some people (like idOS) have begun modifying their schemas with Postgres directly while doing migrations. If this becomes more common user behavior, it might be easier to just make schema names 1-1 with the dbid.

Not anything we need to address right now, just food for though.

@brennanjl brennanjl merged commit be42003 into kwilteam:main Sep 30, 2024
2 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set Replica Identity to full on snapshot restore
2 participants