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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sync map to fix cocurrent write #2918

Merged
merged 2 commits into from Jun 9, 2023
Merged

Conversation

changluyi
Copy link
Collaborator

@changluyi changluyi commented Jun 8, 2023

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes:

Fixes #2907

WHAT

馃 Generated by Copilot at 67e9f20

This pull request enhances the pod deletion logic in the Controller type by using a sync.Map for the deletingPodObjMap field. This improves the thread-safety and performance of the controller when handling pod deletion events. The pull request modifies pkg/controller/controller.go and pkg/controller/pod.go to use the sync.Map type.

馃 Generated by Copilot at 67e9f20

There once was a type called Controller
That managed the pods of a cluster
To delete them with care
It used a sync.Map there
And thus made its performance much bolder

HOW

馃 Generated by Copilot at 67e9f20

  • Replace regular map with sync.Map for deletingPodObjMap field of Controller type to improve thread-safety and avoid concurrent map access errors (link, link)
  • Use Store method of sync.Map to atomically set the value for a key in deletingPodObjMap in various functions that enqueue pod events (link, link, link, link, link, link, link, link)
  • Use Load method of sync.Map to atomically get the value for a key in deletingPodObjMap in functions that process pod deletion events (link, link)
  • Use Delete method of sync.Map to atomically remove the value for a key in deletingPodObjMap in processNextDeletePodWorkItem function (link)
  • Check the second return value of Load method to handle the case where the key is not found in deletingPodObjMap in handleDeletePod function (link)

@changluyi changluyi added this to In progress in 2023-6 via automation Jun 8, 2023
@changluyi changluyi merged commit 517d379 into master Jun 9, 2023
55 of 57 checks passed
2023-6 automation moved this from In progress to Done Jun 9, 2023
@changluyi changluyi deleted the fix_map_concurrent_writes branch June 9, 2023 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

kube-ovn-controller crashes: fatal error: concurrent map writes
2 participants