I have a MySQL (RDS) database that is replicated from one datacenter to another. There is also a message bus which spans these two locations, and it carries messages when certain writes to the database take place.
The messages and the MySQL replication race between the two locations. We need to make sure we don't process the message before the write that it refers to has definitely made it into the replica.
At the moment we use custom "last updated at" field on the tables that are replicated. It seems like there should be a global variable we can use instead though -- something that monotonically increases whenever there's a write anywhere in the database, and is available at both the master and the slave.
Does such a variable exist? Do I need special privileges to read it?
If there is not such a thing, what would be the tradeoffs associated with implementing it ourselves?