Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

fix controller logic to prevent concurrent map reads and writes #28

Merged
merged 1 commit into from
Mar 22, 2021

Conversation

wlan0
Copy link
Contributor

@wlan0 wlan0 commented Mar 22, 2021

There was a special case where under heavy load there was a concurrent map read and write. This fixes that

@wlan0 wlan0 requested review from brahmaroutu and krishchow March 22, 2021 06:21
@wlan0 wlan0 self-assigned this Mar 22, 2021
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 22, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wlan0

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 requested review from msau42 and saad-ali March 22, 2021 06:21
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 22, 2021
Copy link

@krishchow krishchow left a comment

Choose a reason for hiding this comment

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

Minor question

Comment on lines 394 to 403
if op, ok := c.opMap[uuid]; ok {
if op, ok := c.opMap.Load(uuid); ok {
if _, ok := op.(updateOp); ok {
return fmt.Errorf("cannot add already added object: %s", key)
err := fmt.Errorf("cannot add already added object: %s", key)
return err
}
}
c.opMap[uuid] = addOp{
c.opMap.Store(uuid, addOp{
Object: d.Object,
AddFunc: &add,
Key: key,
Indexer: indexer,
}
})

Choose a reason for hiding this comment

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

Could we combine this by using c.opMap.LoadOrStore /nit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@krishchow
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 22, 2021
@k8s-ci-robot k8s-ci-robot merged commit 7c22e78 into kubernetes-retired:master Mar 22, 2021
shanduur pushed a commit to shanduur/container-object-storage-interface-api that referenced this pull request Jun 6, 2024
BlaineEXE pushed a commit to BlaineEXE/cosi-api that referenced this pull request Jun 14, 2024
BlaineEXE pushed a commit to BlaineEXE/cosi-api that referenced this pull request Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants