triggers or else between 2 postgres databases hosted on a different datacenter
I don't think this is a good idea, you should read the documentation on Streaming Synchronous Replication instead which guarantees consistency and is a ton easier to configure.

Even if you're not going to use that, you should consider postgres_fdw instead of the older dblink.