Skip to content
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

KAFKA-17559: Fix the flaky RemoteLogOffsetReader#testTaskQueueFullAndCancelTask #17214

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
reduced the task queue size to 1
  • Loading branch information
kamalcph committed Sep 18, 2024
commit 1a83a24ba81071edfa7aed0dc0d3d061517fbc60
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void setUp() throws IOException {
logDir = Files.createTempDirectory("kafka-test");
LeaderEpochCheckpointFile checkpoint = new LeaderEpochCheckpointFile(TestUtils.tempFile(), new LogDirFailureChannel(1));
cache = new LeaderEpochFileCache(topicPartition, checkpoint, time.scheduler);
rlm = new MockRemoteLogManager(2, 3, logDir.toString());
rlm = new MockRemoteLogManager(2, 1, logDir.toString());
}

@AfterEach
Expand Down Expand Up @@ -98,8 +98,8 @@ public void testTaskQueueFullAndCancelTask() throws Exception {
rlm.pause();

List<AsyncOffsetReadFutureHolder<Either<Exception, Option<TimestampAndOffset>>>> holderList = new ArrayList<>();
// Task queue size is 3 and number of threads is 2, so it can accept at-most 5 items
for (int i = 0; i < 5; i++) {
// Task queue size is 1 and number of threads is 2, so it can accept at-most 3 items
for (int i = 0; i < 3; i++) {
holderList.add(rlm.asyncOffsetRead(topicPartition, time.milliseconds(), 0L, cache, Option::empty));
}
assertThrows(TimeoutException.class, () -> holderList.get(0).taskFuture().get(10, TimeUnit.MILLISECONDS));
Expand All @@ -116,15 +116,15 @@ public void testTaskQueueFullAndCancelTask() throws Exception {
holder.taskFuture().get(1, TimeUnit.SECONDS);
}
}
assertEquals(5, holderList.size());
assertEquals(4, holderList.stream().filter(h -> h.taskFuture().isDone()).count());
assertEquals(3, holderList.size());
assertEquals(2, holderList.stream().filter(h -> h.taskFuture().isDone()).count());
assertEquals(1, holderList.stream().filter(h -> !h.taskFuture().isDone()).count());
}

@Test
public void testThrowErrorOnFindOffsetByTimestamp() throws Exception {
RemoteStorageException exception = new RemoteStorageException("Error");
try (RemoteLogManager rlm = new MockRemoteLogManager(2, 3, logDir.toString()) {
try (RemoteLogManager rlm = new MockRemoteLogManager(2, 1, logDir.toString()) {
@Override
public Optional<TimestampAndOffset> findOffsetByTimestamp(TopicPartition tp,
long timestamp,
Expand Down