1

I have a multi-master replication setup using Postgres and Bucardo. On top of it, I have a Django application.

The setup does not fully works since I keep getting primary-key collisions. Since the replication is configured to clone the whole database, and thus I'm somewhat confident that Postgres' sequence ids are being updated, I wonder if it is not Django that keeps somewhere in memory the last sequential id number. If so, does anyone have any hint on what could be done to fix this issue?

Thanks in advance

rrb_bbr
  • 2,966
  • 4
  • 24
  • 26

1 Answers1

2

Attempting multi-master replication without an idea how to deal with conflicts is foolhardy.

This case is simple: define the sequences on each node so that the values cannot collide. If you have two databases, that would be:

CREATE SEQUENCE tab_id_seq START WITH 1 INCREMENT BY 2;  -- on one database
CREATE SEQUENCE tab_id_seq START WITH 2 INCREMENT BY 2;  -- on the other database

But you will hit other replication conflicts that are harder to resolve.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263