I have a requirement where there are 2 instances of the application on different DCs running. It uses distributed locks so at any given point of time only 1 instance will have the lock. So say instance A has the lock but while running some critical section it loses the lock but it does not know about it so instance B gets the lock. So now before updating the DB instance A checks if it has the lock or not if it does not have the lock it is suppose to exit. I am not sure what is the bets way to handle the exit. I cant just return coz the flow of the code will continue. I was thinking System.exit and then since we use mesos it will start the instance again but wanted to see if there is a better way to handle it.
Asked
Active
Viewed 118 times
0
-
If the "DB" is a relational database, it probably has locking support, it would be simpler to use that. – Pawel Veselov Mar 17 '20 at 18:16
-
Its just not the DB there are other write operations as well so we want to maintain a consistent solution – Sachin Jain Mar 18 '20 at 15:46
-
But your database is a convergence point, so you can use it to synchronize operations that require serialization – Pawel Veselov Mar 19 '20 at 16:16