[Bucardo-general] resolving exceptions by picking both rows

Ben Chobot bench at silentmedia.com
Fri Feb 19 23:51:44 UTC 2021

I'm attempting to write a custom conflict handler that resolves 
exceptions by picking both rows and twiddling as needed, instead of 
chucking one version of a PK, and I keep running into problems. It's no 
longer clear to me if this is something bucardo can even support.

I have this table:

create table versions (
   id serial primary key,
   versionable_id int,
   versionable_type text,
   number int,
   yaml text,
   created_at timestamp
create unique index versions_versionable_id_versionable_type_number_idx 
on versions (versionable_id, versionable_type, number);

When bucardo encounters an exception on that unique index, I would like 
it to keep all rows, and just increment the number column in order of 
created_at to keep that unique constraint happy. It's ok (for me, though 
maybe not for bucardo) if the pk ids change.

What I've tried doing is building up a list of all 
{versionable_id,verisionable_type} pairings of the rows involved in the 
deltabin, then pulling all the rows involved in that pairing from both 
dbs, regardless of if they are or aren't in the deltabin, deleting all 
those rows from both dbs, and then re-inserting them into both dbs with 
tweaked number fields (and different PKs), and finally telling bucardo 
to retry the sync. This works perfectly on one db, but the other db ends 
up with none of the rows. I'm at a loss as to what's going on.

Is this even a conflict resolution model bucardo can handle, where the 
process of conflict resolution removes all the PKs bucardo is working on 
and inserts new ones?

More information about the Bucardo-general mailing list