You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/04/11 04:08:06 UTC

[GitHub] [kafka] dengziming opened a new pull request #10523: MINOR: Optimeze side effect brought by EpochState.canGrantVote

dengziming opened a new pull request #10523:
URL: https://github.com/apache/kafka/pull/10523


   *More detailed description of your change*
   This fixes the discussion https://github.com/apache/kafka/pull/10393#discussion_r608289621
   
   *Summary of testing strategy (including rationale)*
   Unit test
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on a change in pull request #10523: MINOR: Optimeze side effect brought by EpochState.canGrantVote

Posted by GitBox <gi...@apache.org>.
dengziming commented on a change in pull request #10523:
URL: https://github.com/apache/kafka/pull/10523#discussion_r611414661



##########
File path: raft/src/main/java/org/apache/kafka/raft/CandidateState.java
##########
@@ -241,12 +236,14 @@ public int epoch() {
     }
 
     @Override
-    public boolean canGrantVote(int candidateId, boolean isLogUpToDate) {
+    public Optional<String> validateGrantVote(int candidateId, boolean isLogUpToDate) {
         // Still reject vote request even candidateId = localId, Although the candidate votes for
         // itself, this vote is implicit and not "granted".
-        log.debug("Rejecting vote request from candidate {} since we are already candidate in epoch {}",
-            candidateId, epoch);
-        return false;
+        return Optional.of(String.format(
+            "Rejecting vote request from candidate %s since we are already candidate in epoch %s",
+            candidateId,
+            epoch
+        ));

Review comment:
       This is tricky, fortunately, vote request is not a frequent RPC.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ijuma commented on a change in pull request #10523: MINOR: Optimeze side effect brought by EpochState.canGrantVote

Posted by GitBox <gi...@apache.org>.
ijuma commented on a change in pull request #10523:
URL: https://github.com/apache/kafka/pull/10523#discussion_r611216846



##########
File path: raft/src/main/java/org/apache/kafka/raft/CandidateState.java
##########
@@ -241,12 +236,14 @@ public int epoch() {
     }
 
     @Override
-    public boolean canGrantVote(int candidateId, boolean isLogUpToDate) {
+    public Optional<String> validateGrantVote(int candidateId, boolean isLogUpToDate) {
         // Still reject vote request even candidateId = localId, Although the candidate votes for
         // itself, this vote is implicit and not "granted".
-        log.debug("Rejecting vote request from candidate {} since we are already candidate in epoch {}",
-            candidateId, epoch);
-        return false;
+        return Optional.of(String.format(
+            "Rejecting vote request from candidate %s since we are already candidate in epoch %s",
+            candidateId,
+            epoch
+        ));

Review comment:
       One tricky aspect is that we now generate the string even if logging is disabled. Let me think about that a bit more.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org