-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Description
While looking into #61269, I noticed what looks like a dangerous pattern in the poller implementation.
The poller uses context.WithTimeout to add a timeout for the configured Getter. Unfortunately, it sets that timeout to be exactly equal to the configured period: if the Getter runs within that period everything is fine, but if it starts taking marginally longer than the period, it is likely that every call will fail with a deadline exceeded error and whatever the poller is supposed to be doing will fail to make progress:
https://cs.opensource.google/go/x/pkgsite/+/master:internal/poller/poller.go;l=49;drc=694b5d3c2a971c2a1dcdf7ab34e521b762bd326d
Instead, I would generally expect the Getter to be invoked with the same Context that controls the lifetime of the poller overall, so that it will only fail if the Poller is being shut down.
(However, it might make sense to also invoke the onError callback as soon as the call overruns the period, so that it can trigger any monitoring that hooks into that callback.)