[GH-ISSUE #1194] [BUG] Metadata table error with Postgres Replica #422

Closed
opened 2026-02-27 08:17:13 +03:00 by kerem · 5 comments
Owner

Originally created by @azamaulanaaa on GitHub (Jun 28, 2025).
Original GitHub issue: https://github.com/lldap/lldap/issues/1194

Describe the bug
I want to connect lldap with postgresql with replica via wal_level = logical. lldap produce error on intial or successive connection to postgres

To Reproduce
Steps to reproduce the behavior:

  1. Start PostgreSQL database with wal_level = logical
  2. Set lldap with PostgreSQL
  3. start lldap
  4. See error

Expected behavior
Work just fine.

Logs

2025-06-28T09:40:47.782111568+00:00  INFO     set_up_server [ 23.7ms | 95.10% / 100.00% ]
2025-06-28T09:40:47.782159152+00:00  INFO     ┝━ i [info]: Starting LLDAP version 0.6.1
2025-06-28T09:40:47.806475314+00:00  DEBUG    ┝━ get_schema_version [ 1.16ms | 4.90% ]
2025-06-28T09:40:47.810129947+00:00  DEBUG    │  ┕━ 🐛 [debug]:  | return: Some(SchemaVersion(1))
2025-06-28T09:40:47.810181073+00:00  INFO     ┝━ i [info]: Upgrading DB schema from version 1
2025-06-28T09:40:47.810186823+00:00  INFO     ┕━ i [info]: Upgrading DB schema to version 2   
Error: while creating base tables

Caused by:
    0: Execution Error: error returned from database: cannot update table "metadata" because it does not have a replica identity and publishes updates
    1: error returned from database: cannot update table "metadata" because it does not have a replica identity and publishes updates
    2: error returned from database: cannot update table "metadata" because it does not have a replica identity and publishes updates
    3: cannot update table "metadata" because it does not have a replica identity and publishes updates

Additional context
it is fixable through run this sql query then restart lldap

alter table metadata ADD COLUMN id SERIAL; alter table metadata add constraint metadata_pkey primary key (id);
Originally created by @azamaulanaaa on GitHub (Jun 28, 2025). Original GitHub issue: https://github.com/lldap/lldap/issues/1194 **Describe the bug** I want to connect lldap with postgresql with replica via `wal_level = logical`. lldap produce error on intial or successive connection to postgres **To Reproduce** Steps to reproduce the behavior: 1. Start PostgreSQL database with `wal_level = logical` 2. Set lldap with PostgreSQL 3. start lldap 4. See error **Expected behavior** Work just fine. **Logs** ``` 2025-06-28T09:40:47.782111568+00:00 INFO set_up_server [ 23.7ms | 95.10% / 100.00% ] 2025-06-28T09:40:47.782159152+00:00 INFO ┝━ i [info]: Starting LLDAP version 0.6.1 2025-06-28T09:40:47.806475314+00:00 DEBUG ┝━ get_schema_version [ 1.16ms | 4.90% ] 2025-06-28T09:40:47.810129947+00:00 DEBUG │ ┕━ 🐛 [debug]: | return: Some(SchemaVersion(1)) 2025-06-28T09:40:47.810181073+00:00 INFO ┝━ i [info]: Upgrading DB schema from version 1 2025-06-28T09:40:47.810186823+00:00 INFO ┕━ i [info]: Upgrading DB schema to version 2 Error: while creating base tables Caused by: 0: Execution Error: error returned from database: cannot update table "metadata" because it does not have a replica identity and publishes updates 1: error returned from database: cannot update table "metadata" because it does not have a replica identity and publishes updates 2: error returned from database: cannot update table "metadata" because it does not have a replica identity and publishes updates 3: cannot update table "metadata" because it does not have a replica identity and publishes updates ``` **Additional context** it is fixable through run this sql query then restart lldap ``` alter table metadata ADD COLUMN id SERIAL; alter table metadata add constraint metadata_pkey primary key (id); ```
kerem 2026-02-27 08:17:13 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@nitnelave commented on GitHub (Jun 28, 2025):

It doesn't really make sense for the metadata table to have a serial ID. Here, we're kinda abusing the SQL DB to store single scalar values (and currently just one, the migration version), in order to avoid having state anywhere else.

I'm not familiar with postgres replication, so I'm not sure I can help here

<!-- gh-comment-id:3015316037 --> @nitnelave commented on GitHub (Jun 28, 2025): It doesn't really make sense for the metadata table to have a serial ID. Here, we're kinda abusing the SQL DB to store single scalar values (and currently just one, the migration version), in order to avoid having state anywhere else. I'm not familiar with postgres replication, so I'm not sure I can help here
Author
Owner

@azamaulanaaa commented on GitHub (Jun 28, 2025):

Sorry, wal_level = logical is not enough to produce error, it requires a publication. here is how i achieve publication

nerdctl exec -it postgres psql -U postgres -d postgres -c "CREATE PUBLICATION postgres_pub FOR ALL TABLES;"

note

  • nerdctl is replacement for docker
  • postgres is the container name
  • postgres is the postgres user
  • postgres is the database name
<!-- gh-comment-id:3015808297 --> @azamaulanaaa commented on GitHub (Jun 28, 2025): Sorry, `wal_level = logical` is not enough to produce error, it requires a publication. here is how i achieve publication `nerdctl exec -it postgres psql -U postgres -d postgres -c "CREATE PUBLICATION postgres_pub FOR ALL TABLES;"` note - nerdctl is replacement for docker - postgres is the container name - postgres is the postgres user - postgres is the database name
Author
Owner

@azamaulanaaa commented on GitHub (Jun 28, 2025):

given the circumstances that metadata table has, i found the fastest way is to make version column as primary key.

alter table metadata add constraint metadata_pkey primary key (version);

i able to do the pr but i cannot guarantee 100% works as the ci hard to replicate in my side. i need to patch a lot of github ci yaml. as long as it able to compile and pass all the tests, it should be fine right?

<!-- gh-comment-id:3015825169 --> @azamaulanaaa commented on GitHub (Jun 28, 2025): given the circumstances that metadata table has, i found the fastest way is to make version column as primary key. `alter table metadata add constraint metadata_pkey primary key (version);` i able to do the pr but i cannot guarantee 100% works as the ci hard to replicate in my side. i need to patch a lot of github ci yaml. as long as it able to compile and pass all the tests, it should be fine right?
Author
Owner

@nitnelave commented on GitHub (Jun 28, 2025):

I feel like the best solution would be to not create a publication for the metadata table. It only changes on DB migrations, which happen on startup when changing LLDAP versions

<!-- gh-comment-id:3015923456 --> @nitnelave commented on GitHub (Jun 28, 2025): I feel like the best solution would be to not create a publication for the metadata table. It only changes on DB migrations, which happen on startup when changing LLDAP versions
Author
Owner

@azamaulanaaa commented on GitHub (Jun 28, 2025):

sorry, i miss that option.

after looking closely at pgsql docs for publication. pgsql's publication does not include alter table. so metadata table should not include at publication. i will close this issue and the pr. Thank you

<!-- gh-comment-id:3015968164 --> @azamaulanaaa commented on GitHub (Jun 28, 2025): sorry, i miss that option. after looking closely at pgsql docs for publication. pgsql's publication does not include alter table. so `metadata` table should not include at publication. i will close this issue and the pr. Thank you
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/lldap-lldap#422
No description provided.