FIX: Handling abnormal swithover from zk.#867
Merged
jhpark816 merged 1 commit intonaver:developfrom Feb 3, 2025
Merged
Conversation
1286a78 to
0e988d2
Compare
Collaborator
|
@brido4125 |
Contributor
Author
|
혹시 오프라인 설명이 필요하다면 편하게 말해주세요 |
Collaborator
|
설명 한 번 해주세요. |
Contributor
Author
|
PR 코멘트 업데이트 했습니다. |
uhm0311
requested changes
Jan 16, 2025
oliviarla
reviewed
Jan 16, 2025
0e988d2 to
4657886
Compare
4657886 to
ce2f9fc
Compare
uhm0311
reviewed
Jan 17, 2025
uhm0311
reviewed
Jan 17, 2025
uhm0311
previously approved these changes
Jan 17, 2025
jhpark816
reviewed
Jan 20, 2025
Collaborator
jhpark816
left a comment
There was a problem hiding this comment.
리뷰 완료
다른 경우도 확인하여 안전한 방식으로 구현합시다.
ce2f9fc to
542c8c4
Compare
Collaborator
위의 코멘트에 대해서도 검토가 되었나요? |
542c8c4 to
3cad10c
Compare
Collaborator
|
@uhm0311 @oliviarla |
oliviarla
previously approved these changes
Jan 22, 2025
Collaborator
|
@uhm0311 빠른 리뷰 바랍니다. |
Collaborator
|
코드가 많이 간략화되었는데, 각 경우를 어떤 원리로 커버할 수 있는지 설명해주었으면 합니다. |
brido4125
commented
Jan 23, 2025
brido4125
commented
Jan 23, 2025
uhm0311
previously approved these changes
Jan 24, 2025
3cad10c to
2021488
Compare
jhpark816
reviewed
Feb 3, 2025
| // Old master has gone away. And, new group has appeared. | ||
| if (oldGroup.getMasterCandidate() != null) { | ||
| oldGroup.clearMasterCandidate(); | ||
| } |
Collaborator
There was a problem hiding this comment.
slave 제거할 시에 masterCandidate clear하는 것이 좋겠습니다.
for (MemcachedNode oldSlaveNode : oldSlaveNodes) {
removeNodes.add(oldSlaveNode);
// move operation slave -> master.
taskList.add(new MoveOperationTask(
oldSlaveNode, newMasterNode, false));
// clear the masterCandidate if the removed slave is the masterCandidate.
if (oldGroup.getMasterCandidate() == oldSlaveNode) {
oldGroup.clearMasterCandidate();
}
}2021488 to
7e9941c
Compare
jhpark816
approved these changes
Feb 3, 2025
jhpark816
reviewed
Feb 10, 2025
Collaborator
jhpark816
left a comment
There was a problem hiding this comment.
기존 merged PR에 문제가 있어 코멘트 남깁니다.
확인하고, 문제가 있다면 이를 해결하는 PR을 다시 보내주세요.
Collaborator
|
@brido4125 본 PR 코멘트는 다 반영된 상태인거죠? |
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.
🔗 Related Issue
캐시 서버로부터의 응답을 통해 master candidate를 설정하고 난 뒤,
zk로부터 비정상적인 switchover를 감지하는 경우에 대한 처리이다.
이중화
삼중화
참고로 아래와 같은 케이스들은 zk 시퀀스 넘버에 의한
Repl Role 선정 방식에 의해 발생되지 않습니다.
위 표를 참고하여 발생 가능한 비정상 경우들은 아래와 같다.
이중화
삼중화
아래 케이스와 함께 이중화의 비정상 케이스처럼
old Master가 newMaster이고 slave가 모두 떨어진 케이스
⌨️ What I did
비정상 이중화인 경우는 oldMaster와 newMaster가 동일하기 때문에 아래 로직을 따른다.
arcus-java-client/src/main/java/net/spy/memcached/MemcachedConnection.java
Line 470 in f60ed48
비정상 삼중화인 경우는 oldSlaves 내에 newMaster가 있고
newSlaves 내에 oldMaster가 존재하기에 기존의 Switchover 로직을 따른다.
arcus-java-client/src/main/java/net/spy/memcached/MemcachedConnection.java
Lines 490 to 491 in daf6334
두 경우 모두 cache server 응답에 의해 설정된
master candidate에 쌓인 ops 객체들을 oldmaster로 옮겨줘야한다.
이중화의 경우 master candidate를 null로 설정해서 master로 op가 처리되도록 한다.
삼중화는 zk로부터 받은 master를 설정하여
최신 master에 op가 처리되도록 한다.