fix(detector/vuls2): prevent redundant parallel DB downloads in server mode - #2617
Open
maxenced wants to merge 1 commit into
Open
fix(detector/vuls2): prevent redundant parallel DB downloads in server mode#2617maxenced wants to merge 1 commit into
maxenced wants to merge 1 commit into
Conversation
…r mode When multiple HTTP requests arrive while the vuls2 database is stale, each one independently triggered a full download from the OCI registry. This wasted bandwidth and I/O without any coordination. Introduce a single-flight background fetch mechanism: the first request that detects a stale DB spawns an async goroutine to download the update while immediately serving from the current (stale) DB. All concurrent requests that arrive while the download is in flight skip the fetch and use the existing DB. Synchronous (blocking) downloads are preserved for cases where the current DB cannot be used at all: first-ever download or schema version mismatch. Safety guarantees are maintained: if the background fetch fails, temp files are cleaned up by the upstream fetch library and the lock is released so the next request can retry.
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in #2613 , vuls2 has no limit on concurrent download when multiple HTTP requests arrive while the vuls2 database is stale, each one independently triggered a full download from the OCI registry. This wasted bandwidth, disk and I/O without any coordination.
This introduce a single-flight async background fetch mechanism: the first request that detects a stale DB spawns an async goroutine to download the update while immediately serving from the current (stale) DB. All concurrent requests that arrive while the download is in flight skip the fetch and use the existing DB.
This does not fix startup download (which will be part of another PR)
Safety guarantees are maintained: if the background fetch fails, temp files are cleaned up by the upstream fetch library and the lock is released so the next request can retry.
Is this ready for review?: YES