Skip to content

Commit 53298a9

Browse files
docs: component and before/after diagrams for atomic namespace creation
Exported from the Drawr board (https://drawr.quick.shopify.io/b/GNUB8o_56hhfFGxv) and embedded in the design doc.
1 parent bb4d42f commit 53298a9

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎docs/ATOMIC_NAMESPACE_CREATE_DESIGN.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Stacked on `tszymczyszyn/streaming-dump-importer` (PR #51). Fixes the pre-existi
66

77
## 1. Problem
88

9+
![Before and after](images/atomic-namespace-create-before-after.png)
10+
11+
912
`NamespaceStore::create` persists the namespace config **first** and only then runs the configurator's `setup` (directory, logger, connections, dump import). Three resources are mutated without a common commit point:
1013

1114
| Resource | Written at | Cleaned on error | Cleaned on cancellation | Cleaned after crash |
@@ -29,6 +32,11 @@ Non-goals: a server-side import timeout; idempotency keys / async create jobs; b
2932

3033
## 3. Design in one paragraph
3134

35+
![Components and ownership](images/atomic-namespace-create-components.png)
36+
37+
*Who owns what: numbered arrows are the happy path, dashed red the undo. Live board (Shopify-internal, editable): https://drawr.quick.shopify.io/b/GNUB8o_56hhfFGxv — page "Before / after" contrasts the old and new sequence.*
38+
39+
3240
Make the **metastore write the commit point** and make everything before it reversible. `create` reserves the name by write-locking its cache entry, puts the config in the metastore's *in-memory* map only (so `setup` can read it), runs `setup`, and only on success **flushes the row** and installs the namespace. A `Reservation` drop guard undoes the in-memory config if the future ends any other way — error *or* cancellation — and releases the lock only after that, so waiters never observe a half-built namespace. The filesystem gets the same treatment one layer down: `setup` wraps a brand-new directory in a `FreshDir` guard that removes it on drop. For crashes, a brand-new directory carries an `.incomplete` marker until the row is flushed; the next `create` of that name discards a marked directory.
3341

3442
```
120 KB
Loading
192 KB
Loading

0 commit comments

Comments
 (0)