Prevent two way sync from going on an infinite loop

筅森魡賤 提交于 2019-12-11 06:27:30

问题


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?

来源:https://stackoverflow.com/questions/20968758/prevent-two-way-sync-from-going-on-an-infinite-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!