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-17506 KRaftMigrationDriver initialization race #17147

Merged
merged 10 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
7 changes: 5 additions & 2 deletions .github/workflows/deflake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ jobs:
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
- name: Test
timeout-minutes: 60
id: junit-test
run: |
set +e
./gradlew --info --build-cache --scan --continue \
-PtestLoggingEvents=started,passed,skipped,failed \
-PignoreFailures=true -PmaxParallelForks=2 \
-Pkafka.cluster.test.repeat=${{ inputs.test-repeat }} \
${{ inputs.test-module }}:test --tests ${{ inputs.test-pattern }}
exitcode="$?"
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
- name: Archive JUnit reports
if: always()
uses: actions/upload-artifact@v4
id: junit-upload-artifact
with:
Expand All @@ -69,8 +72,8 @@ jobs:
**/build/reports/tests/test/*
if-no-files-found: ignore
- name: Parse JUnit tests
if: always()
run: python .github/scripts/junit.py >> $GITHUB_STEP_SUMMARY
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }}
GRADLE_EXIT_CODE: ${{ steps.junit-test.outputs.exitcode }}
4 changes: 2 additions & 2 deletions core/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n

log4j.logger.kafka=INFO
log4j.logger.org.apache.kafka=INFO
log4j.logger.kafka=WARN
log4j.logger.org.apache.kafka=WARN

# zkclient can be verbose, during debugging it is common to adjust it separately
log4j.logger.org.apache.zookeeper=WARN
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ public String name() {
@Override
public void onControllerChange(LeaderAndEpoch newLeaderAndEpoch) {
curLeaderAndEpoch = newLeaderAndEpoch;
if (migrationState.equals(MigrationDriverState.UNINITIALIZED)) {
eventQueue.append(new RecoverMigrationStateFromZKEvent());
}
eventQueue.append(new KRaftLeaderEvent(newLeaderAndEpoch));
}

Expand Down Expand Up @@ -519,7 +522,7 @@ public void run() throws Exception {
KRaftMigrationDriver.this.image = image;
String metadataType = isSnapshot ? "snapshot" : "delta";

if (migrationState.equals(MigrationDriverState.INACTIVE)) {
if (EnumSet.of(MigrationDriverState.UNINITIALIZED, MigrationDriverState.INACTIVE).contains(migrationState)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice! Not only onControllerChange, but all OnMetadataChange will cause race condition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this race is harmless since onMetadataChange does not alter the state machine state and most of its logic is guarded behind if (!migrationState.allowDualWrite()) {. But it's good to have this for completeness.

// No need to log anything if this node is not the active controller
mumrah marked this conversation as resolved.
Show resolved Hide resolved
completionHandler.accept(null);
return;
Expand Down
Loading