Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/pkgsite/internal/poller: risk of starvation if the Getter starts taking too long #62200

Open
bcmills opened this issue Aug 21, 2023 · 1 comment
Assignees
Labels

Comments

@bcmills
Copy link
Contributor

bcmills commented Aug 21, 2023

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.)

@gopherbot gopherbot added this to the Unreleased milestone Aug 21, 2023
@gopherbot
Copy link

Change https://go.dev/cl/521656 mentions this issue: internal/poller: fix starvation if Poll takes longer than period

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants