You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c06d945
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/PLAN.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ If two processes insert concurrently, Postgres accepts one insert and rejects th
129
129
130
130
### Redis distributed lock and fencing
131
131
132
-
First, implement a Redis lease:
132
+
First, implement a Redis lock:
133
133
134
134
```text
135
135
SET lock:<key> <owner-token> NX PX <ttl>
@@ -141,7 +141,7 @@ The owner-token check makes release safe, but it does not make an expired owner
141
141
142
142
```text
143
143
A acquires the lock
144
-
A pauses until its lease expires
144
+
A pauses until its lock expires
145
145
B acquires the lock and writes
146
146
A resumes and tries to write
147
147
```
@@ -150,14 +150,14 @@ A must not be allowed to write after B. Checking the token during release only s
150
150
151
151
The owner token above is a random identity: it answers "is this still my lock?" A fencing token is different. It is an increasing number that records the order in which owners acquired the lock.
152
152
153
-
Postgres remembers the highest fencing token it has accepted and rejects a write carrying an older token. A resumed owner can therefore be recognized as stale even after its Redis lease expires.
153
+
Postgres remembers the highest fencing token it has accepted and rejects a write carrying an older token. A resumed owner can therefore be recognized as stale even after its Redis lock expires.
154
154
155
155
Fencing and optimistic locking both use conditional database writes, but their values mean different things:
156
156
157
157
- An optimistic-lock version is read from the database row. The write succeeds only if that row still has the same version.
158
158
- A fencing token represents the order in which owners acquired the lock. The database rejects an owner older than one it has already accepted.
159
159
160
-
Using `UPDATE ... WHERE version = $expected` alongside Redis can still be a valid design, but it combines the Redis lease with optimistic locking. It is not, by itself, a fencing-token implementation.
160
+
Using `UPDATE ... WHERE version = $expected` alongside Redis can still be a valid design, but it combines the Redis lock with optimistic locking. It is not, by itself, a fencing-token implementation.
Copy file name to clipboardExpand all lines: docs/tests-overview.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ DB constraint ✓ ✓
58
58
59
59
That will make the limitation of an in-memory mutex extremely concrete. The mutex isn’t defective; its synchronization boundary is simply the Node process.
60
60
61
-
A lease-only Redis lock can pass ordinary contention tests across processes while its TTL remains valid, but it fails the expired-holder scenario shown below. The checkmarks therefore apply to Redis combined with storage-layer validation, such as fencing.
61
+
A lock-only Redis lock can pass ordinary contention tests across processes while its TTL remains valid, but it fails the expired-holder scenario shown below. The checkmarks therefore apply to Redis combined with storage-layer validation, such as fencing.
62
62
63
63
## Redis progression
64
64
@@ -69,7 +69,7 @@ token-safe release
69
69
↓
70
70
"so distributed locking is solved?"
71
71
↓
72
-
NO — lease expires while A is paused
72
+
NO — lock expires while A is paused
73
73
↓
74
74
B obtains lock
75
75
↓
@@ -111,7 +111,7 @@ test/
111
111
redis-fencing/
112
112
contract.test.ts
113
113
lock-ownership.test.ts
114
-
lease-expiry.test.ts
114
+
lock-expiry.test.ts
115
115
fencing.test.ts
116
116
topology.test.ts
117
117
@@ -134,6 +134,6 @@ The worker and parent-side IPC barrier are shared infrastructure: build them
134
134
for the keyed-mutex topology test, then reuse them for the remaining strategy
135
135
directories.
136
136
137
-
Redis has additional files because acquiring and safely releasing a lease,
137
+
Redis has additional files because acquiring and safely releasing a lock,
138
138
demonstrating expiry failure, and rejecting stale writers through fencing are
0 commit comments