FIX: Concurrency problem in locator allNodes.#769
Open
brido4125 wants to merge 1 commit intonaver:developfrom
Open
FIX: Concurrency problem in locator allNodes.#769brido4125 wants to merge 1 commit intonaver:developfrom
brido4125 wants to merge 1 commit intonaver:developfrom
Conversation
uhm0311
requested changes
Jul 2, 2024
oliviarla
previously approved these changes
Jul 2, 2024
uhm0311
reviewed
Jul 2, 2024
uhm0311
approved these changes
Jul 3, 2024
Collaborator
|
@oliviarla 리뷰 바랍니다. |
oliviarla
approved these changes
Jul 4, 2024
Collaborator
Author
|
오프라인에서 말씀하신 사항에 대한 답변입니다. MemcachedNode getNodeForKey(long hash) {
lock.lock();
try {
if (ketamaNodes.isEmpty()) {
return null;
}
Map.Entry<Long, SortedSet<MemcachedNode>> entry = ketamaNodes.ceilingEntry(hash);
if (entry == null) {
entry = ketamaNodes.firstEntry();
}
return entry.getValue().first();
} finally {
lock.unlock();
}
} |
Collaborator
|
@oliviarla 한번 더 점검하고, 의견주세요. |
Collaborator
|
@jhpark816 |
Collaborator
Author
|
어떤 관점에서 점검을 지시 하셨는지는 모르겠는데, 추가적으로 locator를 리팩토링하는 설계에 있어 |
Collaborator
|
@brido4125 rebase 해 주시죠. |
Collaborator
Author
|
본 PR은 현재 진행중인 이슈(Locator 공유)에 의해서 변경될 가능성이 굉장히 높습니다. 그래서 close를 시켜놓고 보류하려고 합니다. |
Collaborator
|
@brido4125 @uhm0311 @oliviarla |
Collaborator
|
충돌 난거만 해결하면 될 것 같습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이슈
https://github.com/jam2in/arcus-works/issues/490#issuecomment-2199206597
위 코멘트 말고도 Braodcast 연산 시에 getAll()을 호출하는데
read는 worker-thread 로 write는 IO 스레드에 의해서
ConcurrentModificationException이 발생할 수도 있습니다.
왜냐하면 기존 구현은 리턴되는 Collections.unmodifiableCollection이
allNodes 참조와 연결되어있기 때문입니다.
반환 값에 새로운 참조를 넣어서 기존 allNodes 참조와의
연결을 끊어주면 동시성 문제가 발생하지 않습니다.
다른 대안으로는
new CopyOnWriteArrayList<>(allNodes);와 같은 타입을 리턴할 수도 있습니다.다만 alterNodes와의 구현 통일성 때문에 현재 구현을 채택했습니다.
참고로 alterNodes는 위와 같이 서로 다른 스레드가
각각 동시에 read/write 하는 로직이 존재하지 않습니다.