Skip to content

ADR-0018 — The fence token

  • Status: Accepted
  • Date: 2026-11-13
  • Supersedes: none
  • Authors: project maintainers

Context

The fence (ADR-0017) needs a token that a read hands out and a later put returns. A thread can be deleted and re-created, or copied, and a token from before must never match the new thread (the ABA problem).

Decision

The token will be [thread_id, generation, checkpoint_id], with the generation drawn from one global sequence, so a deleted, re-created or copied thread never matches an old token.

Alternatives considered

  • A per-row counter — rejected: it restarts after delete_thread, and a stale token matches again.
  • The head checkpoint id as the version — rejected: copy_thread keeps checkpoint ids, so a re-copied thread can get its old head back.

Consequences

  • One nextval per root put.
  • The token rides in the returned config and parent_config; listing does not put one in its configs (ADR-0027).

References