Quick revision
The short answer
After the maintenance, that VM's clock was 94 seconds off, so every absolute time its pods wrote disagreed with the rest of the fleet: expiry times they stamped on cache entries had already passed by the other pods' clocks, and issued-at times on their tokens lay in the other pods' future, so both checks failed elsewhere. The immediate fix is to drain the node, force a clock correction with chronyc makestep and confirm the offset is small before returning it. To tolerate clock errors, expiry should be relative and enforced by one authority, token checks should allow a bounded skew, every node's offset should be monitored, and correctness should never depend on comparing the wall clocks of different machines.
What to remember
In this answer, we traced both symptoms to one node whose clock was 94 seconds off after maintenance: expiry times its pods wrote were already past for other pods, and issued-at times on its tokens lay in their future, with the sign of the offset, read from chronyc tracking, deciding which check fails. We drained the node, forced a correction with chronyc makestep, confirmed the offset and fixed the chrony configuration. Then we made the system tolerant: relative TTLs enforced by Redis, bounded skew for tokens, offset monitoring with automatic cordoning, and leases with fencing tokens instead of comparing wall clocks.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
After the maintenance, that VM's clock was 94 seconds off, so every absolute time its pods wrote disagreed with the rest of the fleet: expiry times they stamped on cache entries had already passed by the other pods' clocks, and issued-at times on their tokens lay in the other pods' future, so both checks failed elsewhere. The immediate fix is to drain the node, force a clock correction with chronyc makestep and confirm the offset is small before returning it. To tolerate clock errors, expiry should be relative and enforced by one authority, token checks should allow a bounded skew, every node's offset should be monitored, and correctness should never depend on comparing the wall clocks of different machines.
Why this question is asked
Clock problems are among the hardest incidents to diagnose, because nothing logs 'my clock is wrong'; instead, unrelated features fail in ways that look like bugs in cache and authentication code. Interviewers ask this scenario to see whether we can connect two strange symptoms to one cause, read the evidence carefully, fix the node safely, and then change the design so the next bad clock is harmless. In this answer, we will recap why absolute times are fragile, trace each symptom to the offset, fix the node, and make the system tolerate clock errors.
1A Quick Recap: Absolute Times Assume Shared Clocks
An absolute time is a point on the calendar, such as expiresAt = 10:01:00 or issuedAt = 10:00:00. When one machine writes it and another machine compares it with its own clock, the comparison is only meaningful if both clocks agree. A relative time, such as expire in 60 seconds, is interpreted by whoever enforces it, using one clock.
Normally chrony keeps the nodes within a millisecond of each other, so absolute times work. After host maintenance, a VM that was paused or live-migrated can resume with a clock that is far off and has not yet been corrected. chronyc tracking on the bad node showing a 94-second offset tells us exactly that: until chrony steps or slews it back, every time that node writes is off by 94 seconds, and every time it checks is judged against a wrong 'now'.
2How the Offset Breaks Each Check
Take the cache first. A pod on the bad node writes an entry with a 60-second lifetime and stamps expiresAt = its now + 60 s. If that clock is 94 seconds behind the fleet, the stamp is already 34 seconds in the past by everyone else's clock, so any other pod that reads the entry treats it as expired at once. Every entry from that node is effectively uncacheable for the rest of the fleet, which shows up as a sudden drop in hit rate and extra database load.
Now the tokens. A token carries an issued-at time (iat) from the issuer's clock, and verifiers reject tokens whose iat lies in their future, because a token cannot be issued later than now. A token stamped by a clock that differs from the verifier's by 94 seconds in the forward direction fails that check on every other pod.
Notice that the two symptoms are produced by opposite signs of the same kind of error: an expiry that has already passed means the writer's clock was behind, and an issued-at time in the future means the issuer's clock was ahead. So part of the diagnosis is reading the sign from chronyc tracking (it says 'slow of NTP time' or 'fast of NTP time') and checking the timeline. A VM typically resumes from a pause behind, and a host-side time jump or an over-eager correction can push it ahead later, so a node can produce both symptoms during one maintenance window. Either way, the root cause is the same: one node's wall clock disagreeing with the fleet by tens of seconds, and code that trusts it.
5 messages in order. Play them, or step through them one at a time.
Whichever way the clock is off, any check that compares two machines' clocks can fail.
3Fixing the Immediate Problem
First, stop the damage: cordon and drain the node so no new pods land there and existing pods move to healthy nodes. Then correct the clock. chronyc makestep forces an immediate step instead of a slow slew; alternatively, restart the time service, which steps on start if configured to. We confirm with chronyc tracking that the offset is back in the sub-millisecond range and that chrony is synchronised to a source.
Only then do we uncordon the node. We also let the bad cache entries expire or clear them, and look for the root cause: why did chrony not correct the clock after the VM resumed? Often the configuration allows stepping only during the first few updates after start (the limit in the makestep directive), so a large offset found later is slewed at a limited rate, which would take many hours to remove 94 seconds.
4Making the System Tolerate Clock Errors
The lasting fix is design. Cache expiry should be relative and enforced by one authority. Instead of each writer computing expiresAt from its own clock, the writer says 'keep this for 60 seconds' and the cache server enforces it with its single clock, for example SET key value EX 60 in Redis. Now the writers' clocks do not matter at all.
Token validation should allow a bounded skew. JWT libraries let us accept an iat or nbf slightly in the future and an exp slightly in the past, typically 30 to 60 seconds, which absorbs ordinary skew without opening a real hole. It would not have hidden 94 seconds, and it should not: that is a fault we want to see.
We monitor clock offset on every node, using chrony's own metrics or the node exporter's timex metrics, and alert, or automatically cordon the node, when the offset exceeds a threshold such as 100 ms. A node problem detector can taint the node so the scheduler avoids it until the clock recovers.
| Concern | Fragile design | Tolerant design |
|---|---|---|
| Cache expiry | absolute expiresAt from writer's clock | relative TTL enforced by Redis (EX 60) |
| Token time checks | exact comparison of iat and exp | bounded skew allowance, 30-60 s |
| Clock health | noticed when features break | offset alert or auto-cordon at 100 ms |
| Locks and ordering | compare wall clocks across hosts | leases with fencing tokens, versions |
5Never Rely on Comparing Clocks for Correctness
The broader rule is that correctness must never depend on two machines' wall clocks agreeing. Lock expiry is the classic trap: a lock that 'expires at 10:05:00' as judged by different machines can be held by two of them at once. Leases should be granted by one authority with fencing tokens, increasing numbers that the protected resource checks, so a stale holder's writes are rejected. Ordering updates should use versions or logical clocks, not timestamps.
Wall-clock times remain useful for display, logs and rough retention. This incident shows where the line is: anything that decides whether data is valid, fresh or allowed should depend on one clock, or on no clock at all.
6Follow-up questions
Why does chrony not always fix a large offset by itself?
By default chrony corrects gradually by slewing, and many configurations allow a step only in the first few updates after start. A large offset discovered later is corrected at a limited rate, which can take many hours for 94 seconds. A makestep directive with a step limit of -1 allows stepping whenever the offset exceeds the threshold.
Is stepping the clock on a running node safe?
It can make wall-clock-based timeouts misbehave, which is why we drain the node first. Code that uses the monotonic clock for durations is unaffected, another reason to use it for timeouts.
What is a sensible skew allowance for tokens?
Usually 30 to 60 seconds. Larger allowances extend the life of stolen tokens, and with offset monitoring at 100 ms, honest skew should never come close to the limit.
7Conclusion
In this answer, we traced both symptoms to one node whose clock was 94 seconds off after maintenance: expiry times its pods wrote were already past for other pods, and issued-at times on its tokens lay in their future, with the sign of the offset, read from chronyc tracking, deciding which check fails. We drained the node, forced a correction with chronyc makestep, confirmed the offset and fixed the chrony configuration. Then we made the system tolerant: relative TTLs enforced by Redis, bounded skew for tokens, offset monitoring with automatic cordoning, and leases with fencing tokens instead of comparing wall clocks.
Open with
The node came back from maintenance with its clock 94 seconds off, which chronyc tracking shows, and chrony hadn't stepped it back, probably because it's only allowed to step right after starting and otherwise slews slowly.
Then, if they want more
Everything that compares a time written on that node with another node's clock then breaks. Cache entries carry an absolute expiry computed from the writer's clock, so when the writer is behind, the other pods see the expiry as already passed and treat the entry as expired immediately.
Tokens carry an issued-at time from the issuer's clock, so when the issuer's clock is ahead of the verifier's, the token looks issued in the future and is rejected. I'd check the sign in chronyc and the timeline, because those two symptoms come from opposite directions, which happens when a VM resumes behind and then gets pushed the other way.
Immediately, I'd cordon and drain the node, run chronyc makestep, confirm the offset is sub-millisecond, fix the makestep setting so large offsets get stepped any time, and uncordon.
To tolerate it next time, I'd use relative TTLs enforced by one authority, like EXPIRE in Redis, allow 30 to 60 seconds of skew in token checks, alert or auto-cordon when a node's offset goes above about 100 milliseconds, and never rely on comparing different machines' wall clocks for correctness, using leases with fencing tokens or versions instead.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Explain how one node's clock caused both symptoms, how you would fix the immediate...": https://scrivio-interview-library.netlify.app/architecture/distributed-systems/bfa88261dc/