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

fix: lru race condition #30335

Merged
merged 1 commit into from
Aug 9, 2023
Merged

fix: lru race condition #30335

merged 1 commit into from
Aug 9, 2023

Conversation

rjsadow
Copy link
Contributor

@rjsadow rjsadow commented Aug 9, 2023

There are ongoing failures in the pull-test-infra-unit-test-race-detector-nonblocking jobs. The failures are related to concurrent access to the underlying LRU cache within the NewInRepoConfigCache function, specifically between the lruCache.Keys() and lruCache.GetOrAdd() calls. These conflicting accesses are causing a data race, as the underlying LRU cache implementation (github.com/hashicorp/golang-lru) does not handle concurrent reads and writes safely. The proposed fix involves adding synchronization around LRU cache Keys operation to ensure that only one goroutine can access the cache at a time, thereby preventing the race condition. Locks are already in place for the GetOrAdd operation.

ref: https://kubernetes.slack.com/archives/C09QZ4DQB/p1691588437957859

/cc @listx

Signed-off-by: rjsadow <richard.j.sadowski@gmail.com>
@k8s-ci-robot k8s-ci-robot requested a review from listx August 9, 2023 16:40
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. area/prow Issues or PRs related to prow labels Aug 9, 2023
@rjsadow rjsadow changed the title fix lru race condition fix: lru race condition Aug 9, 2023
@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Aug 9, 2023
@rjsadow
Copy link
Contributor Author

rjsadow commented Aug 9, 2023

@listx
Copy link
Contributor

listx commented Aug 9, 2023

Ah, good catch. Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 9, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: listx, rjsadow

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 9, 2023
@k8s-ci-robot k8s-ci-robot merged commit b1472a3 into kubernetes:master Aug 9, 2023
7 checks passed
@rjsadow rjsadow deleted the race-fix branch August 9, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants