Skip to content

Implemented the poll chain to await the download future that serialize polling - #169

Open
polachandu wants to merge 3 commits into
open-policy-agent:mainfrom
polachandu:fix/serialize-bundle-polling
Open

Implemented the poll chain to await the download future that serialize polling#169
polachandu wants to merge 3 commits into
open-policy-agent:mainfrom
polachandu:fix/serialize-bundle-polling

Conversation

@polachandu

@polachandu polachandu commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Re-serialize by chaining each poll off the previous download's completion instead of a fixed timer — the same "single serial loop" guarantee that Go-OPA has. This makes bundle (and discovery) polling strictly serial, so overlapping polls can no longer run activateBundle() — and thus mutate the shared Store — concurrently.

Added a test confirming that downloads remain serialized even when activation exceeds the poll interval, so overlapping downloads cannot trigger concurrent activateBundle() calls.

Closes #113

Signed-off-by: Chandrahas Reddy Pola <polachandrahas@gmail.com>
Signed-off-by: Chandrahas Reddy Pola <polachandrahas@gmail.com>
@polachandu
polachandu force-pushed the fix/serialize-bundle-polling branch from dad3896 to 9cf6dfe Compare July 24, 2026 05:46
Signed-off-by: Chandrahas Reddy Pola <polachandrahas@gmail.com>
@polachandu
polachandu marked this pull request as ready for review July 24, 2026 06:27
@polachandu
polachandu requested a review from a team as a code owner July 24, 2026 06:27
@polachandu

Copy link
Copy Markdown
Contributor Author

Hi @sspaink, please review this PR. Please post your comments/suggestions if any, happy to incorporate.

delay,
() ->
downloadBundle()
.whenComplete(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request has no .timeout(...) and the clients only set connectTimeout. Java's HttpClient has no default response timeout, so a server that accepts and never replies leaves sendAsync pending forever: whenComplete never fires, scheduleDownload is never called again, and polling stops permanently with nothing logged.

One line next to requestBuilder.build() fixes it:

requestBuilder.timeout(Duration.ofSeconds(/* e.g. the service's responseHeaderTimeoutSeconds */));

The timeout fails the future, handleHttpResponse logs it, and the chain keeps polling. (Prefer this over .orTimeout(...), which doesn't cancel the request — the stalled exchange could still land later and call activateBundle alongside a fresh poll.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BundleDownloader: async download allows overlapping polls → concurrent activateBundle/Store mutation

2 participants