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

fixing hasher is not consistent when getting multiple request at the same time #773

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

kongbong
Copy link
Contributor

@kongbong kongbong commented Jan 4, 2023

GetByClusterIdentity() is protected by RLock but multiple read request can be called as it is read lock.
And fnv.New32a is not thread safe hasher so hasher.Write() function can be called at the same time and hash result is inconsistent.

so that messages can be sent to wrong cluster.

I changed to make new hasher every time it called and fnv.New32a() has very light weight so I think it is fine for performance as well. only problem can be increasing GC count but hasher is not escape from hash() function so I think it is allocated in stack memory so I think GC count will be not increased.

I added test case for verifying this problem. without this change, the test will be failed.

@CLAassistant
Copy link

CLAassistant commented Jan 4, 2023

CLA assistant check
All committers have signed the CLA.

@kongbong kongbong changed the title fixing hasher is not consistent when getting multiple request for the same time fixing hasher is not consistent when getting multiple request at the same time Jan 4, 2023
@rogeralsing rogeralsing merged commit 31163d7 into asynkron:dev Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants