Repository navigation
resolve race condition in result deduplication cache - #5359
Merged
kvnphvm merged 1 commit intoSep 30, 2026
Merged
Conversation
rosecodym
approved these changes
Sep 29, 2026
kvnphvm
deleted the
int-1085-resolve-race-condition-in-result-deduplication-cache
branch
September 30, 2026 16:24
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.
Description:
Between checking if a result is in the deduplication cache and adding it, another goroutine could add it, or it could be evicted. This contributes to varying result counts.
Change to ContainsOrAdd so that it is one atomic step
Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Medium Risk
Changes concurrent deduplication on the shared notifier dispatch path, which directly affects reported finding counts; scope is narrow and covered by new concurrency tests.
Overview
Fixes inconsistent finding counts when multiple notifier workers process the same scan result at once.
The notifier dedupes non-reverification results (
SecretID == 0) via a shared LRU cache keyed by an MD5 of detector name, type, raw secret, and source metadata. That path used a separate lookup then insert, so two workers could both see a miss and dispatch the same finding twice. The change replaces that withContainsOrAddso check-and-insert is one step, with a short comment that the cache is shared across workers.Tests add a mutex on
captureDispatcherfor concurrent notifier use, andTestNotifierWorker_ConcurrentDuplicatesDispatchedOnceruns 16 workers over 1,000 distinct secrets with 16 copies each (cache sized to avoid eviction) and asserts exactly one dispatch per secret.Reviewed by Cursor Bugbot for commit 5c5e416. Bugbot is set up for automated code reviews on this repo. Configure here.