pglogical: Changefeed with PK updated is incorrectly populated to target
Opened this issue · 0 comments
ZhouXing19 commented
For pg>crdb case, I noticed if the original mutation is to update the pk of a row, replicator will actually insert a new row on target, rather than updating the existing one.
E.g. with employee_id
the PK of the employees
table,
UPDATE employees
SET employee_id = 20 -- New unique ID
WHERE employee_name = 'Bob Smith';
which results in the following in the source db:
defaultdb=# SELECT * FROM employees;
employee_id | employee_name | department
-------------+---------------+------------
1 | Alice Johnson | HR
3 | Charlie Brown | IT
4 | David Wilson | Marketing
5 | Eva Davis | Sales
20 | Bob Smith | Finance
but on target:
root@localhost:26258/defaultdb> SELECT * FROM employees;
employee_id | employee_name | department
--------------+---------------+-------------
1 | Alice Johnson | HR
2 | Bob Smith | Finance
3 | Charlie Brown | IT
4 | David Wilson | Marketing
5 | Eva Davis | Sales
20 | Bob Smith | Finance
It means the UPSERT happened with employee_id=20
in the where clause, rather than employee_id=2
.