Skip to content

Fix recovered consensus pipes staying stopped after snapshot load#17438

Open
Pengzna wants to merge 2 commits intoapache:masterfrom
Pengzna:codex/fix-consensus-pipe-snapshot-recovery
Open

Fix recovered consensus pipes staying stopped after snapshot load#17438
Pengzna wants to merge 2 commits intoapache:masterfrom
Pengzna:codex/fix-consensus-pipe-snapshot-recovery

Conversation

@Pengzna
Copy link
Copy Markdown
Collaborator

@Pengzna Pengzna commented Apr 7, 2026

Summary

  • recover healthy consensus pipes as RUNNING during ConfigNode snapshot load
  • preserve STOPPED status for consensus pipes stopped by runtime exception
  • add coverage for recovered consensus pipe status normalization

Validation

  • ran JAVA_HOME=$(/usr/libexec/java_home -v 17) mvn -pl iotdb-core/confignode -Dspotless.skip=false spotless:apply
  • attempted mvn -pl iotdb-core/confignode -Dtest=PipeTaskInfoConsensusPipeTest test earlier, but dependency resolution was too slow in the current environment

Copilot AI review requested due to automatic review settings April 7, 2026 14:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes ConfigNode recovery behavior so consensus pipes loaded from a snapshot don’t remain incorrectly STOPPED after restart, while still preserving STOPPED state for pipes halted due to runtime exceptions.

Changes:

  • Normalize recovered consensus pipe statuses to RUNNING during PipeTaskInfo.processLoadSnapshot, except for pipes marked as stopped by runtime exception.
  • Add a unit test covering snapshot take/load and verifying the expected status normalization behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java Normalizes recovered consensus pipe runtime status after snapshot load.
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfoConsensusPipeTest.java Adds snapshot recovery test ensuring only healthy stopped consensus pipes are restarted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +985 to +989
LOGGER.info(
"Recovered consensus pipes {} as RUNNING during snapshot load.", restartedConsensusPipes);
}
}

Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The INFO log prints the full list of restarted consensus pipe names, which can be very large (consensus pipes scale roughly with N*(N-1) per region). This may bloat logs during snapshot recovery; consider logging only the count (and optionally a small sample) at INFO, and the full list at DEBUG.

Suggested change
LOGGER.info(
"Recovered consensus pipes {} as RUNNING during snapshot load.", restartedConsensusPipes);
}
}
final List<String> restartedConsensusPipeSample =
samplePipeNamesForInfoLog(restartedConsensusPipes, 10);
LOGGER.info(
"Recovered {} consensus pipes as RUNNING during snapshot load. Sample: {}{}",
restartedConsensusPipes.size(),
restartedConsensusPipeSample,
restartedConsensusPipes.size() > restartedConsensusPipeSample.size() ? " ..." : "");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Recovered consensus pipes {} as RUNNING during snapshot load.",
restartedConsensusPipes);
}
}
}
private List<String> samplePipeNamesForInfoLog(
final List<String> pipeNames, final int maxSampleSize) {
return new ArrayList<>(pipeNames.subList(0, Math.min(pipeNames.size(), maxSampleSize)));
}

Copilot uses AI. Check for mistakes.
Comment on lines +204 to +207
} finally {
new File(snapshotDir, "pipe_task_info.bin").delete();
snapshotDir.delete();
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

Test cleanup hard-codes the snapshot file name ("pipe_task_info.bin") and ignores delete() results. Consider deleting the temp directory recursively (and/or deleting all files under snapshotDir) so cleanup doesn't depend on PipeTaskInfo's private snapshot filename and doesn’t silently leak temp dirs if deletion fails.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants