refactor: use monotonic clock for circuit breaker and auto-recovery#617
refactor: use monotonic clock for circuit breaker and auto-recovery#617unsafePtr wants to merge 1 commit into
Conversation
While auditing for the changes in this PR, the in-process L1 freshness check came up as a separate candidate — same shape as open-telemetry/opentelemetry-dotnet#7253, but with a tighter design constraint that kept it out of the present PR. Sites (all in
Why it's not in this PR: Why it's worth doing eventually: cache TTL windows are minutes-to-hours rather than seconds, so the bug-class exposure window is much larger than the deadline gates in this PR; the failure mode (cache stampede on forward NTP step, stale data on backward step) is also more visible than a circuit-breaker blip. Same Tier 1 case OTel addressed in #7253. Confirmed-skip (no fix possible/needed because they cross a process boundary): Happy to open a separate PR for the L1 freshness piece if there's interest — wanted to flag the audit notes here first rather than doing it as drive-by scope-creep. |
Switch SimpleCircuitBreaker and AutoRecoveryService from
DateTimeOffset.UtcNowbased deadlines toStopwatch.GetElapsedTime. Both are in-process deadline gates; their elapsed-time math should be unaffected by wall-clock adjustments (NTP correction, manual clock change).Same change was recently added by me to dotnet/runtime#127303. I am flagging this as a refactor, since in-process deadline gates should be measured monotonically, even though using DateTime.UtcNow in this use-case will probably never lead to problems in practice. This mirrors open-telemetry/opentelemetry-dotnet#7193 (sweep) and open-telemetry/opentelemetry-dotnet#7253 (in-process freshness check).
Wall-clock usage is preserved for serialized timestamps (LogicalExpirationTimestamp, BackplaneMessage.Timestamp, AutoRecoveryItem expiration) since those cross process boundaries.