Subject Re: [ib-support] Re: Changing Insert to Update.
Author Svein Erling Tysvær
Sorry John, there's one thing I don't understand: Why can't you
guarantee that the PK is the same on both servers? I think it should be
pretty simple given that you know the number of servers. Just make sure
that
a) the key is only generated if not supplied explicitly.
b) multiply the generator with the number of servers (or a higher number
if you want a "buffer") and add a set number to each of the servers.

So, with your two servers, assign 0 as the set number for one of them
and 1 for the other. Always multiply your generated value by 2 and add
the set number. Then one of the servers will create the records with
even key numbers, whereas the other will make odd numbers. When
transferring records to the other server, remember to transfer the key
as well, and you've got your unique key across both servers. I've never
done this myself, but it doesn't sound very difficult to implement and
it guarantees you unique identifiers.

Just some rambling from a lazy programmer more concerned about making
things work than coming up with fancy solutions,
Set

John Peterson wrote:
> My Unique Constraint and the issue of non atomic key is a bit tricky, since
> the application is part of a replication system.
> The data is being fed to 2 servers via 2 feeds. I have PK in each (atomic
> via Generator), however I cannot guarantee that for a given record, the PK
> will have the same value on each server (100 things could go wrong to get
> them out of step).
> What I am left with is using a few columns to generate a Unique key.
> Fortunately, users are not entering data into these, only the data feed.
>
> Enough of ramble.
> Thanks again for your invaluable input
> John