canonical / canonical/postgresql-k8s-operator

Logical replication creates infinite loop of inserts

Open
#1,052 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
15
Forks
34
Avg merge
1d 3h
Merged PRs (30d)
41

Description

## Steps to reproduce

1. juju deploy postgresql-k8s --channel 16/edge --trust postgresql1
2. juju deploy postgresql-k8s --channel 16/edge --trust postgresql2
3. juju deploy data-integrator di1 --config database-name=testdb
4. juju deploy data-integrator di2 --config database-name=testdb
5. juju integrate postgresql1 di1
6. juju integrate postgresql2 di2
7. juju integrate postgresql1:logical-replication-offer postgresql2:logical-replication
8. juju integrate postgresql1:logical-replication postgresql2:logical-replication-offer
9. juju run di1/leader get-credentials
10. psql `PSQL URI FROM ABOVE`
11. create table asd (message int);\q
12. juju run di2/leader get-credentials
13. psql `PSQL URI FROM ABOVE`
14. create table asd (message int);\q
15. juju config postgresql1 logical_replication_subscription_request='{"testdb": ["public.asd"]}'
16. juju config postgresql2 logical_replication_subscription_request='{"testdb": ["public.asd"]}'

## Expected behaviour
A blocked status message telling that the same table cannot be defined on both sides of the relation for the logical replication.

## Actual behaviour

An infinite loop of inserts happens due to the cyclic replication that was configured by configuring the same table on both sides of the relation.

## Versions

Operating system: Ubuntu 24.04

Juju CLI: 3.6.8

Juju agent: 3.6.8

Charm revision: 638

microk8s: 1.32-strict/stable

## Log output

Juju debug log: no relevant logs.

## Additional context

The table needs to be empty in both clusters; otherwise, the charm will properly set a blocked status indicating the table is not empty in one of the clusters.

This is the same situation as reported at https://github.com/canonical/postgresql-operator/issues/1085.

Contributor guide

Open the contributing guide

Research direction

Reproduce the cycle using the listed Juju deployments, the logical-replication relations, and matching subscription requests for public.asd. Inspect the charm's logical-replication configuration and status handling; done means both applications report a blocked status explaining that the same table cannot be defined on both sides, instead of endlessly inserting.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, postgresql, python
Domain
databases, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.