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 concurrent map iteration & write issue #329

Conversation

Blaxon
Copy link
Contributor

@Blaxon Blaxon commented Mar 8, 2023

The issue was introduced in func (l *fileStore) Remove(addr string) error
https://github.com/qiniu/goc/blob/master/pkg/cover/store.go#L107

when we set the memory server list back to file.
the list l.memoryStore.GetAll() -> services passed into func (l *fileStore) Set(services map[string][]string) error
in L175 we sign the services directly to l.memoryStore.servicesMap, without copying it.

while in L186 we are still using this map to do the iteration without lock. (by right should use memoryStore.mu.

The issue will happen when there is another goroutine tries to remove the server from memoryStore. Map will clash.

@Blaxon
Copy link
Contributor Author

Blaxon commented Mar 8, 2023

Solve issue: #324

@CarlJi
Copy link
Collaborator

CarlJi commented Mar 8, 2023

/assign @CarlJi

@qiniu-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Blaxon
To complete the pull request process, please assign carlji
You can assign the PR to them by writing /assign @carlji in a comment when ready.

The full list of commands accepted by this bot can be found 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

@qiniu-bot qiniu-bot added size/M and removed size/S labels Mar 10, 2023
@Blaxon
Copy link
Contributor Author

Blaxon commented Mar 10, 2023

Hi @CarlJi , I just made a new commit

  1. to fix the fileStore.Remove data inconsistency issue,
  2. and update the unit test to be verifiable.
    Pls help check, Thanks!

@Blaxon Blaxon force-pushed the bugfix/issue-56552/fix-concurrent-map-iteration-writing branch from b5f944c to 267535a Compare March 10, 2023 03:07
@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #329 (b6cebb2) into master (5868a3e) will decrease coverage by 0.25%.
The diff coverage is 76.19%.

❗ Current head b6cebb2 differs from pull request most recent head 00142a6. Consider uploading reports for the commit 00142a6 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #329      +/-   ##
==========================================
- Coverage   70.76%   70.51%   -0.25%     
==========================================
  Files          34       34              
  Lines        2035     2042       +7     
==========================================
  Hits         1440     1440              
- Misses        482      489       +7     
  Partials      113      113              
Flag Coverage Δ
e2e-1.16.x ?
e2e-1.17.x ?
e2e-1.18.x ?
e2e-1.19.x ?
unittest-1.16.x 70.51% <76.19%> (-0.15%) ⬇️
unittest-1.17.x 70.51% <76.19%> (-0.15%) ⬇️
unittest-1.18.x 70.51% <76.19%> (-0.15%) ⬇️
unittest-1.19.x 70.51% <76.19%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/cover/instrument.go 20.83% <ø> (ø)
pkg/cover/store.go 81.45% <76.19%> (-2.58%) ⬇️

... and 1 file with indirect coverage changes

@CarlJi CarlJi merged commit 2a2162e into qiniu:master Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants