← All projects
Project record1 mention
Originally shared on Hacker News

TLA+ spec of an eventually consistent tree-move algorithm

A TLA+ specification (translated from a simplified multithreaded Java simulation using LLMs) of a distributed, eventually consistent algorithm for storing a tree in a database. Users can move a node from one parent to another in parallel while the tree must never exceed max depth or contain cycles; a per-node height field is kept eventually consistent via optimistic locking (version checks/CAS), with height increases applied transactionally up front and decreases propagated by background jobs. The spec is checked with TLC model checking, using symmetry optimizations to extend exhaustive checking, and the author is seeking further performance improvements.

Last shared
01 / The problem

What it addresses

Concurrent node-move requests in a database-stored tree must never break the max-depth or no-cycle invariants, even though height updates are only eventually consistent.

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. TLA+ spec of an eventually consistent tree-move algorithm

    A TLA+ specification (translated from a simplified multithreaded Java simulation using LLMs) of a distributed, eventually consistent algorithm for storing a tree in a database. Users can move a node from one parent to another in parallel while the tree must never exceed max depth or contain cycles; a per-node height field is kept eventually consistent via optimistic locking (version checks/CAS), with height increases applied transactionally up front and decreases propagated by background jobs. The spec is checked with TLC model checking, using symmetry optimizations to extend exhaustive checking, and the author is seeking further performance improvements.

    Problem: Concurrent node-move requests in a database-stored tree must never break the max-depth or no-cycle invariants, even though height updates are only eventually consistent.

    Posted by @daxfohl · Original source ↗

    Source text · @daxfohl · · Source ↗

    It simulates storing a tree in a database, where users can move a node from one parent to another, and those requests can happen in parallel, with the requirement that the tree is never more than N deep, and does not contain cycles.