BASE style databases are Soft State and Eventually Consistent. I'm aware that different database management systems vary and their configurations make a huge difference. But let's imagine this:
Let's say I have a NoSQL cluster with 2 nodes. It's eventually consistent. When I write to Node1, it's replicated to Node2 after some time. Let me implement an Optimistic Locking mechanism by comparing the versions. So, when I try to write to Node1, write operation will not be successful if my version is behind the version in the database. But when there are two threads (or process) try to update the same row, something like this can happen:
- thread1 reads the data with version=0 from Node1
- thread2 reads the data with version=0 from Node2
- thread1 updates the data with version=1 on Node1
- thread2 tries to update the data with version=1 on Node2 and it may success because write operation may not be replicated yet.
Am I missing something? How do some BASE style database systems solve this? Can you give me solid examples about which database system solves this problem how?