hachikuji opened a new pull request, #12538:
URL: https://github.com/apache/kafka/pull/12538

   We have been seeing a few exceptions like the following when running 
integration tests:
   ```
   [2022-08-18 13:02:59,470] ERROR [ControllerApis nodeId=3000] Unexpected 
error handling request RequestHeader(apiKey=FETCH, apiVersion=13, 
clientId=raft-client-0, correlationId=7) -- 
FetchRequestData(clusterId='txpo87ZUSbGSeV2v7H0n_w', replicaId=0, 
maxWaitMs=500, minBytes=0, maxBytes=8388608, isolationLevel=0, sessionId=0, 
sessionEpoch=-1, topics=[FetchTopic(topic='__cluster_metadata', 
topicId=AAAAAAAAAAAAAAAAAAAAAQ, partitions=[FetchPartition(partition=0, 
currentLeaderEpoch=1, fetchOffset=6, lastFetchedEpoch=1, logStartOffset=-1, 
partitionMaxBytes=0)])], forgottenTopicsData=[], rackId='') with context 
RequestContext(header=RequestHeader(apiKey=FETCH, apiVersion=13, 
clientId=raft-client-0, correlationId=7), 
connectionId='127.0.0.1:63113-127.0.0.1:63114-0', clientAddress=/127.0.0.1, 
principal=User:ANONYMOUS, listenerName=ListenerName(CONTROLLER), 
securityProtocol=PLAINTEXT, 
clientInformation=ClientInformation(softwareName=apache-kafka-java, 
softwareVersion=unknown), fromPrivilegedLi
 stener=false, 
principalSerde=Optional[org.apache.kafka.common.security.authenticator.DefaultKafkaPrincipalBuilder@201038c3])
 (kafka.server.ControllerApis:76)
   java.util.concurrent.CompletionException: java.util.NoSuchElementException: 
key not found: BROKER_NOT_AVAILABLE
        at 
java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
        at 
java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
        at 
java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:936)
        at 
java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
        at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
        at 
java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
        at 
org.apache.kafka.raft.KafkaRaftClient.lambda$handleRequest$19(KafkaRaftClient.java:1666)
        at 
java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
        at 
java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
        at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
        at 
java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
        at 
kafka.raft.TimingWheelExpirationService$TimerTaskCompletableFuture.run(TimingWheelExpirationService.scala:32)
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
   Caused by: java.util.NoSuchElementException: key not found: 
BROKER_NOT_AVAILABLE
   ```
   There are basically two causes for this error. First, we were not shutting 
down the timer services in `RaftManager` which are used in the purgatory 
implementation. This meant that operations remaining in purgatory could be 
completed even after `RaftManager` was shutdown. Second, the shutdown order in 
`KafkaClusterTestKit` was problematic. The `RaftManager` instance depends on 
the `SocketServer` in `ControllerServer`, but it was the latter that was 
shutdown first. Instead, we should shutdown `RaftManager` first as we do in 
`KafkaRaftServer`. 
   
   ### 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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to