Repository navigation
fix(tsa): gate on the clock's post-correction error, not the raw offset - #369
Merged
Merged
Conversation
Engine.succeed() stored LastOffset as the offset measured before any correction, and the TSA clock gate treated that as the clock's current error. A step corrects the offset down to roughly its root distance plus half the round-trip delay, but the gate kept judging it by the size of the correction that was just applied, so a boot step larger than max_clock_error_ms left every TSA request refused with timeNotAvailable until the next poll, even though the clock was already correct. Add last_sync_error to TimeSyncStatus: for a step, the residual actually passed to Clock.MarkSynced; for a slew, the full offset measured, since a slew has not caught up to it yet. ClockGate and EstimatedClockError now read that field instead of last_offset. last_offset keeps its old meaning (the pre-correction measurement) for display. Refs #364 Signed-off-by: Bugs5382 <12115015+Bugs5382@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Refs #364
A boot-time clock step larger than
pki.tsa.max_clock_error_msleft every TSArequest refused with
timeNotAvailableuntil the engine's next periodic poll(up to
MinPoll, 64s later), even though the step had already corrected theclock.
Engine.succeed()recordedLastOffsetas the offset measuredbefore correction, and
tsa.ClockGate/EstimatedClockErrortreated thatvalue as the clock's current error, conflating "how far off the clock was
found to be" with "how far off it still is" after the correction was applied.
Design (as decided before coding, per the issue):
LastOffsetkeeps itsexisting meaning (the pre-correction measurement;
TestBootSyncStepsALargeOffsetis unchanged). A new field,
last_sync_erroronTimeSyncStatus, is set bysucceed():Clock.MarkSynced(rootdistance plus half the round-trip delay);
caught up to its offset yet when the round finishes, so there is no
conflation to fix on that path.
tsa.ClockGateandEstimatedClockErrornow readlast_sync_error(plusdrift since the sync) instead of
last_offset. No extra settle poll wasadded; the fix only changes which figure the gate trusts.
This intentionally changes what
tsa.ClockGate's unit tests feed it:internal/tsa/clock_test.go'sgoodSynchelper now setslast_sync_error(the field the gate actually reads) alongside
last_offset, andinternal/init/tsa_test.go's fixture sets both fields too. Two new tablecases cover a large raw offset with a small post-correction residual
(granted) and a small raw offset with a genuinely large post-correction
residual (still refused).
Verification
How this was verified
TestBootSyncStepRecordsSyncErrorFromRootDistance,
TestBootSyncSlewSyncErrorIsTheFullOffset) and two new tsa.TestClockGate
cases were confirmed to fail for the right reason against the old code
(reverted locally, re-ran, then restored) before being left green against
the fix.
post-correction residual instead of the raw offset.