1

I am working on two way sync between two databases, something like what cloudconnect.com did. I am using DB triggers to send data back and forth between the DB's. I was wondering whether I could prevent the PG database in the local from calling the update trigger when the update is done from the remote DB (preventing continuous looping).

I tried using SET session_replication_role: 'replica', which worked, but this will also violate the database integrity by disabling the column constrains.

I was then thinking to have a extra field called disable_trigger and set it to true in the query in which I want the trigger to not happen. But I don't want to change the schema of the database.

Can anyone suggest a way to do this?

sawa
  • 165,429
  • 45
  • 277
  • 381
Charizard_
  • 1,215
  • 1
  • 9
  • 20
  • 2
    Why are you trying to re-invent Slony? http://www.postgresql.org/docs/9.3/static/different-replication-solutions.html – Denis de Bernardy Jan 07 '14 at 10:25
  • Not only that, this sounds like you're reinventing master-master replication. Why? – mcfinnigan Jan 07 '14 at 10:29
  • Basically, the remote DB that I was talking about is the salesforce API. The local one is postgres. – Charizard_ Jan 07 '14 at 10:42
  • 2
    DIY is unwise here. Use one of the established solutions like Slony-I or Bucardo. (BTW, future PostgreSQL versions may support this natively; see http://wiki.postgresql.org/wiki/BDR_User_Guide) – Craig Ringer Jan 07 '14 at 11:20
  • 1
    See also a slightly later post by user ID closely associated with this one: http://stackoverflow.com/q/20970221/398670 – Craig Ringer Jan 07 '14 at 11:42

0 Answers0