firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Improve conflict resolution on replica when table have both Primary and Unique keys

Open hvlad opened this issue 1 year ago • 4 comments

The setup is the same as in #8040:

  • replica database contains a table with Primary Key and at least one Unique Key
  • the record is being inserted and violates UK (not PK!)

Currently, PK violation on insert is resolved by updating conflicting record, using the PK fields values.

But case with UK violation can't be resolved as engine tries to find record for update using PK and such record obviously can't be found, thus original error is returned. This stops replication until manual correction by DBA.

Improvement is to update record using not PK but the unique index that was violated on insert. In this case record exists and can be updated. Replication process will continue.

hvlad avatar Mar 13 '24 08:03 hvlad

Do I assume right that you update PK values to new ones?

aafemt avatar Mar 13 '24 09:03 aafemt

Do I assume right that you update PK values to new ones?

Sure.

hvlad avatar Mar 13 '24 09:03 hvlad

If it is prohibited by some FK which error is returned by IReplicator::process()? Original UK violation or snowballed FK violation?

aafemt avatar Mar 13 '24 10:03 aafemt

I suppose, FK violation. Didn't check it.

hvlad avatar Mar 13 '24 10:03 hvlad

@@@ QA issue @@@ Test not needed, see test for #8040

pavel-zotov avatar Mar 23 '24 20:03 pavel-zotov