gaurav-narula commented on code in PR #21244:
URL: https://github.com/apache/kafka/pull/21244#discussion_r2659985331
##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -5527,7 +5537,7 @@ class ReplicaManagerTest {
replicaManager.alterReplicaLogDirs(Map(tp ->
newReplicaFolder.getAbsolutePath))
// Prevent promotion of future replica
-
doReturn(false).when(spiedPartition).maybeReplaceCurrentWithFutureReplica()
+ blockPromotion.set(true)
Review Comment:
I think this is racey. What if the test thread is interrupted and
`ReplicaAlterDirsThread` invokes
`spiedPartition.maybeReplaceCurrentWithFutureReplica()` before this line
executes?
Perhaps consider a CAS within doAnswer instead?
##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -5514,6 +5514,16 @@ class ReplicaManagerTest {
try {
val spiedPartition = spy(Partition(tpId, time, replicaManager))
+
+ val blockPromotion = new AtomicBoolean(false)
Review Comment:
I think the spied call might still not be visible to the
`ReplicaAlterLogDirsThread`. IIUC, the visibility across threads can only be
enforced through some synchronization.
--
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]