[ 
https://issues.apache.org/jira/browse/KAFKA-7180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16561406#comment-16561406
 ] 

ASF GitHub Bot commented on KAFKA-7180:
---------------------------------------

lindong28 closed pull request #5387: KAFKA-7180: Fixing the flaky test 
testHWCheckpointWithFailuresSingleLogSegment
URL: https://github.com/apache/kafka/pull/5387
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala 
b/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala
index 880950ae02c..1bd15f7b537 100755
--- a/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala
+++ b/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala
@@ -143,6 +143,15 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
       leader == 0 || leader == 1)
 
     assertEquals(hw, hwFile1.read.getOrElse(topicPartition, 0L))
+    /** We plan to shutdown server2 and transfer the leadership to server1.
+      * With unclean leader election turned off, a prerequisite for the 
successful leadership transition
+      * is that server1 has caught up on the topicPartition, and has joined 
the ISR.
+      * In the line below, we wait until the condition is met before shutting 
down server2
+      */
+    waitUntilTrue(() => 
server2.replicaManager.getPartition(topicPartition).get.inSyncReplicas.size == 
2,
+      "Server 1 is not able to join the ISR after restart")
+
+
     // since server 2 was never shut down, the hw value of 30 is probably not 
checkpointed to disk yet
     server2.shutdown()
     assertEquals(hw, hwFile2.read.getOrElse(topicPartition, 0L))


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> In testHWCheckpointWithFailuresSingleLogSegment, wait until server1 has 
> joined the ISR before shutting down server2
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-7180
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7180
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Lucas Wang
>            Assignee: Lucas Wang
>            Priority: Minor
>             Fix For: 2.0.0, 2.1.0
>
>
> In the testHWCheckpointWithFailuresSingleLogSegment method, the test logic is 
> 1. shutdown server1 and then capture the leadership of a partition in the 
> variable "leader", which should be server2
> 2. shutdown server2 and wait until the leadership has changed to a broker 
> other than server2
> through the line 
> waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, oldLeaderOpt 
> = Some(leader))
> However when we execute step 2 and shutdown server2, it's possible that 
> server1 has not caught up with the partition, and has not joined the ISR. 
> With unclean leader election turned off, the leadership cannot be transferred 
> to server1, causing the waited condition in step 2 to be never met. 
> The obvious fix is to wait until server1 has joined the ISR before shutting 
> down server2.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to