Skip to content

KAFKA-19299: Fix race condition in RemoteIndexCacheTest #19927

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

UladzislauBlok
Copy link
Contributor

@UladzislauBlok UladzislauBlok commented Jun 8, 2025

This MR should be couple of race conditions in RemoteIndexCacheTest.

  1. There was a race condition between cache-cleanup-thread and test thread, which wants to check that cache is gone. This was fixed with TestUtils#waitForCondition
  2. After each test we check that there is not thread leak. This check wasn't working properly as alive status is set an JVM level (private native void interrupt0(); method), and we don't really know when it will be set. To fix this I've refactored TestUtils#assertNoLeakedThreadsWithNameAndDaemonStatus method to also use TestUtils#waitForCondition. This fix should also affect few other tests, which were flaky because of this check. See gradle run on develocity

After fix test were run 10000 times with repeated test annotation:

./gradlew clean storage:test --tests org.apache.kafka.storage.internals.log.RemoteIndexCacheTest.testCacheEntryIsDeletedOnRemoval
...
Gradle Test Run :storage:test > Gradle Test Executor 20 > RemoteIndexCacheTest > testCacheEntryIsDeletedOnRemoval() > repetition 9998 of 10000 PASSED
Gradle Test Run :storage:test > Gradle Test Executor 20 > RemoteIndexCacheTest > testCacheEntryIsDeletedOnRemoval() > repetition 9999 of 10000 PASSED
Gradle Test Run :storage:test > Gradle Test Executor 20 > RemoteIndexCacheTest > testCacheEntryIsDeletedOnRemoval() > repetition 10000 of 10000 PASSED
BUILD SUCCESSFUL in 20m 9s
148 actionable tasks: 148 executed

@github-actions github-actions bot added triage PRs from the community producer tests Test fixes (including flaky tests) storage Pull requests that target the storage module clients small Small PRs labels Jun 8, 2025
@UladzislauBlok UladzislauBlok changed the title [WIP] Fix race condition in RemoteIndexCacheTest KAFKA-19299: Fix race condition in RemoteIndexCacheTest Jun 8, 2025
Copy link

A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the triage label
should be removed to prevent this automation from happening again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved clients needs-attention producer small Small PRs storage Pull requests that target the storage module tests Test fixes (including flaky tests) triage PRs from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants