Fencing tokens
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
make stale holders harmless.
Planned topics
- A fencing token is a number that increases every time the lock is granted.
- The holder sends the token with each write; the resource rejects writes with a token lower than one it has seen.
- The check must be at the resource (database, storage), not only in the client.
- In SQL: store
last_tokenand addWHERE last_token <= :tokento the update. - A version column or a monotonically increasing sequence can provide the token.
Draft outline details
Demonstration
UPDATE recon_state SET last_token = :t, result = :r
WHERE id = 1 AND last_token <= :t; -- 0 rows updated: you are stale, stopCheck your understanding
Where must the token be checked?
Show answer
At the resource being written, not just in the client.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.