'Master-slave database replication: How to handle key repeat
Suppose we have a master-slave replication for a database system. Master node goes down, and suppose it has some of the writes which are not yet replicated to any slave node yet. So now system makes one of the follower as leader, meaning when older leader comes back its unreplicated writes are discarded.
Suppose system is using an autoincrement strategy for key generation, as a result new leader may generate keys which were already generated by older leader when it was up and running.
This may cause data consistency issue, particularly if data is consumed by some other systems, like cache. Cache may have key from older leader, but with new leader same key is now pointing to different data.
How is such a problem handled?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
