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

pglogical: Changefeed with PK updated is incorrectly populated to target #1057

Open
ZhouXing19 opened this issue Oct 28, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@ZhouXing19
Copy link
Contributor

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.

@ZhouXing19 ZhouXing19 added the bug Something isn't working label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant