Skip to content

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

@bcmills

Description

@bcmills

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.pkgsite

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions