[Bucardo-general] Bucardo 5.1.1 bucardo_purge_delta for Cascaded Slave

Abdul Yadi abdulyadi.datatrans at gmail.com
Sun Sep 14 10:28:51 UTC 2014


Hi team,

Today I have noticed that for Cascaded Slave Replication, there is
something to do with bucardo_purge_delta function.

Scenario:
Table A (master) => Table B (slave) => Table C (cascaded slave)

Every change on A replicated to B then to C.
After a while, VAC successfully clean delta and track tables on A, but not
on B.

Table B is listed only one on bucardo.bucardo_delta_targets. While, bucardo
registered 2 records on track table, both for A->B and B->C syncs. That is
why delta and track records never cleaned up by this SQL in the
bucardo_purge_delta function (drows is 1 taken from
bucardo.bucardo_delta_targets):

'DELETE FROM bucardo.'
  || deltatable
  || ' USING (SELECT txntime AS tt FROM bucardo.'
  || tracktable
  || ' GROUP BY 1 HAVING COUNT(*) = '
  || drows
  || ') AS foo'
  || ' WHERE txntime = tt'
  || ' AND txntime < now() - interval '
  || quote_literal($1);

I managed to fix it by modify filter from [HAVING COUNT(*)=] to [HAVING
COUNT(*)>=], as follows:

'DELETE FROM bucardo.'
  || deltatable
  || ' USING (SELECT txntime AS tt FROM bucardo.'
  || tracktable
  || ' GROUP BY 1 HAVING COUNT(*) >= '
  || drows
  || ') AS foo'
  || ' WHERE txntime = tt'
  || ' AND txntime < now() - interval '
  || quote_literal($1);

Please advise whethre it is valid.

Regards,
Abdul Yadi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.endcrypt.com/pipermail/bucardo-general/attachments/20140914/947cc2e4/attachment-0001.html>


More information about the Bucardo-general mailing list