Bounding retries of write-write conflicts in MVCC+2PL

Snapshot Isolation, Multi-versioning, & Two-phase Locking§

It is common to implement snapshot isolation using multi-versioning and two-phase locking (specifically write-locks). Much has been written on the benefits of two-phase locking: once a transaction obtains a write lock, it is not possible for there to be any new write-write conflicts on the protected resource (a row predicate, table, etc). This means with two-phase locking, you can detect a write-write conflict at the time of the write. But little has been openly written on approaches to handling and retrying those write-write conflicts once detected. This post will dive into possible approaches.

Let's start with a quick refresh of how snapshot isolation works with MVCC+2PL. It allows for non-blocking snapshot reads (reads as of a version) as they don't need to obtain any locks (remember that SI does not detect read-write conflicts). Write transactions also perform non-blocking snapshot reads, and then before performing a write (and the conflict check), they obtain a lock protecting the resource. The conflict check is simply seeing if anything has been written after the transaction's read version. The benefit of obtaining that lock is well known: once a transaction obtains the write lock, it is not possible for there to be any new write-write conflicts on the protected resource (a row, predicate, table, etc.).

NixOS Configuration with Flakes

My Flakes Philosophy§

In this blog post I will overview how to setup flakes with NixOS and home-manager, and my approach to system configuration. I will also take care to introduce the Nix language and provide links to learning more. This is the first post in my NixOS Desktop series which I will use to explore my Nix and Linux journey. I installed Linux/NixOS for the first time one month ago so it is following me in real time from beginner to eventually, hopefully master :). This post is heavy on the Nix as I am laying the foundation for future posts. But in the future expect it to be much more balanced. For a sneak peek of what is to come check out my dotfiles.