[Bucardo-general] Possible race condition in onetimecopy ?
michelle at sorbs.net
Thu Nov 24 09:32:18 UTC 2011
Rainer Brestan wrote:
> During checking of Bucardo.pm for little improvements in handling of target database restarts, I have found a possible race condition in the KID.
> Maybe I am right, maybe wrong, thats why i am asking.
> Sync type is pushdelta with onetimecopy=1 (Bucardo 4.4.6).
> During execution of onetimecopy not zero, the KID copy the data from source to target with
> COPY $S.$T TO STDOUT and
> COPY $S.$T FROM STDIN
> After this command has finished, it does a REINDEX if necessary.
> After reindex, deletes older entries in bucardo_delta.
> It does it with
> DELETE FROM bucardo.bucardo_delta WHERE txntime <= now() ...
> Here might be a possible race condition.
> Assuming a client makes updates to the source table ($S.$T) between end of COPY command and the DELETE command.
> The trigger applied on the source table will create a entry in bucardo_delta.
> But the DELETE command will remove this entry from bucardo_delta and the affected rows from source table will not be in the target table.
> The COPY command has not seen the update and pushdelta does not know anything about the change, because it is deleted from bucardo_delta.
> Should the time in the DELETE command be compared to the time before start of COPY ?
> Have I missed something else ?
You missed that it's all done in a single transaction...
More information about the Bucardo-general