Serializable Isolation is the only way to prevent all write-related race conditions


Last Updated on Feb 18, 2021

Many databases can automatically detect lost updates. Even when databases don't support this feature, it is possible to avoid data corruption with object-level locks or atomic write operations.

But not all race conditions can be prevented with these measures. Some subtler conflicts, like Write Skews can continue to happen because they do not update the same object. We can avoid this situation by Materializing Conflicts and forcing transactions to try to update the same object, but concurrency-related concerns leak into the application's data model.

The only guaranteed mechanism to prevent all write-related race conditions is to force all transactions to run serially. Many databases support this type of serial execution with the help of Serializable Isolation.

Considered the strongest isolation level, serializable isolation guarantees that even though transactions may execute in parallel, the end result is the same as if they had executed one at a time, serially, without any concurrency. The database guarantees that if the transactions behave correctly when run individually, they continue to be correct when run concurrently.

In other words, the database prevents all possible race conditions.


© 2022 Ambitious Systems. All Rights Reserved.