Design fencing tokens for locks
Prompt that designs fencing tokens for distributed locks and prevents split-brain after expiry. Paste it into an AI tool of your choice, which then designs fencing tokens for locks.
- Topic
- Apps & prototypes
- Type
- Prompt
- Level
- Intermediate
- Time
- about 15 min
Results depend on the tool, the model and what you enter.
Result preview
Example: written by our editors, not real AI output.
Resource: order-queue Lock: Redis SET NX PX 30000 Problem: holder expired, still writing Token: monotonic int in storage Write only if token >= stored Reject: 409 + re-acquire Test: old holder after TTL, new holder wins
Fill in
What you type stays in this browser window. We store and send nothing.
- account balance
- order queue
- config writes
- file index
- mixed
- Redis lock with TTL
- DB row lock
- app lease
- none
- unclear
- double booking
- overwritten config
- suspicion under load
- prevention
- after a timeout bug
Your prompt
You have edited the prompt. Changes in the fields above no longer overwrite it.
This is an instruction for an AI, not the result itself.
Where this prompt works
These AI tools are a good fit for this prompt:
How to use it
- Fill in the fields or tap a suggestion. Leave out names, addresses and other personal data.
- Copy the finished prompt into an AI tool of your choice.
- Paste lock code, TTL and an example of competing writers, without production secrets.
Why does this work?
A lock expires and the old worker still writes. Without fencing, storage accepts both. With a token, only the higher number wins.
Tips
- Store the token next to the value and hard-reject smaller numbers.