-
Notifications
You must be signed in to change notification settings - Fork 47
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
CLEANUP: Refactored MemcachedConnection.switchoverMemcachedReplGroup()
method.
#852
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료입니다.
fd4eeeb
to
fbae49b
Compare
} else { | ||
getLogger().warn("Delay switchover because invalid group state : " + group); | ||
} | ||
((ArcusReplKetamaNodeLocator) locator).switchoverReplGroup(group); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존처럼 group.getMasterNode() != null && group.getMasterCandidate() != null
조건이 만족할 때에만 switchover + move operation + old master reconnect 해야 하지 않나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/jam2in/arcus-works/issues/637#issuecomment-2521925920
해당 조건에 맞지 않는데도 이 메소드를 호출하는 경우가 로직적으로는 없어서 조건문을 제거했습니다.
그래도 조건문을 유지하도록 할까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private 메서드라서 반드시 유지할 필요는 없어보이지만, 단순 검증 용도로 둔다면 나중에 리팩토링 시에 이 부분을 인지하여 버그 발생 가능성이 줄어들 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래와 같이 조건을 넣어 두시죠.
- oldMaster는 분명히 존재하는 상황에서 switchover 대상이 될 수 있음.
- masterCandidate가 null인 경우는 없을 것으로 보이지만,
masterCandidate가 null인 경우에 locator.switchoverReplGroup(group) 수행은
오동작(invalid group으로 변환)하게 되므로,
masterCandidate != null 조건을 넣어두는 것이 괜찮을 것 같습니다.
if (group.getMasterCandidate() != null) {
((ArcusReplKetamaNodeLocator) locator).switchoverReplGroup(group);
. . .
queueReconnect(oldMaster, ReconnDelay.IMMEDIATE,
"Discarded all pending reading state operation to move operations.");
} else {
getLogger().warn("Delay switchover because invalid group state : " + group);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료
@@ -978,6 +976,7 @@ private void handleWrites(MemcachedNode qa) | |||
|
|||
private void handleReads(MemcachedNode qa) | |||
throws IOException { | |||
MemcachedReplicaGroup group = qa.getReplicaGroup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
복제하지 않는 경우에서 위의 코드는 불필요합니다.
group 변수가 실제로 필요한 곳으로 위의 코드를 옮기면 좋겠습니다.
qa.getReplicaGroup().masterNode == qa) { | ||
delayedSwitchoverGroups.remove(qa.getReplicaGroup()); | ||
switchoverMemcachedReplGroup(qa, false); | ||
if (group.isDelayedSwitchover() && group.masterNode == qa) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group.masterNode
대신에 group.getMasterNode()
호출합시다.
MemcachedNode newMaster = group.getMasterNode(); | ||
|
||
oldMaster.moveOperations(newMaster, cancelNonIdempotent); | ||
addedQueue.offer(group.getMasterNode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addedQueue.offer(newMaster);
이면 됩니다.
} else { | ||
getLogger().warn("Delay switchover because invalid group state : " + group); | ||
} | ||
((ArcusReplKetamaNodeLocator) locator).switchoverReplGroup(group); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래와 같이 조건을 넣어 두시죠.
- oldMaster는 분명히 존재하는 상황에서 switchover 대상이 될 수 있음.
- masterCandidate가 null인 경우는 없을 것으로 보이지만,
masterCandidate가 null인 경우에 locator.switchoverReplGroup(group) 수행은
오동작(invalid group으로 변환)하게 되므로,
masterCandidate != null 조건을 넣어두는 것이 괜찮을 것 같습니다.
if (group.getMasterCandidate() != null) {
((ArcusReplKetamaNodeLocator) locator).switchoverReplGroup(group);
. . .
queueReconnect(oldMaster, ReconnDelay.IMMEDIATE,
"Discarded all pending reading state operation to move operations.");
} else {
getLogger().warn("Delay switchover because invalid group state : " + group);
}
fbae49b
to
1815502
Compare
🔗 Related Issue
⌨️ What I did
MemcachedNode
에서MemcachedReplicaGroup
으로 변경합니다.