-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix recovered consensus pipes staying stopped after snapshot load #17438
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| import java.io.File; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
@@ -149,4 +150,60 @@ public void testGetConsensusPipeStatusMapExcludesSubscriptionPipes() { | |
| Assert.assertTrue(result.containsKey(consensusPipeName)); | ||
| Assert.assertFalse(result.containsKey(subscriptionPipeName)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testProcessLoadSnapshotRestartsOnlyHealthyStoppedConsensusPipes() throws Exception { | ||
| DataRegionId regionId = new DataRegionId(100); | ||
| String consensusPipeToRestart = new ConsensusPipeName(regionId, 1, 2).toString(); | ||
| String consensusPipeStoppedByException = new ConsensusPipeName(regionId, 2, 1).toString(); | ||
| String userPipeName = "userPipe"; | ||
|
|
||
| createPipe(consensusPipeToRestart, PipeStatus.STOPPED); | ||
| createPipe(consensusPipeStoppedByException, PipeStatus.STOPPED); | ||
| createPipe(userPipeName, PipeStatus.STOPPED); | ||
|
|
||
| pipeTaskInfo | ||
| .getPipeMetaByPipeName(consensusPipeStoppedByException) | ||
| .getRuntimeMeta() | ||
| .setIsStoppedByRuntimeException(true); | ||
|
|
||
| final File snapshotDir = | ||
| java.nio.file.Files.createTempDirectory("pipe-task-info-consensus-test").toFile(); | ||
| try { | ||
| Assert.assertTrue(pipeTaskInfo.processTakeSnapshot(snapshotDir)); | ||
|
|
||
| PipeTaskInfo recoveredPipeTaskInfo = new PipeTaskInfo(); | ||
| recoveredPipeTaskInfo.processLoadSnapshot(snapshotDir); | ||
|
|
||
| Assert.assertEquals( | ||
| PipeStatus.RUNNING, | ||
| recoveredPipeTaskInfo | ||
| .getPipeMetaByPipeName(consensusPipeToRestart) | ||
| .getRuntimeMeta() | ||
| .getStatus() | ||
| .get()); | ||
| Assert.assertEquals( | ||
| PipeStatus.STOPPED, | ||
| recoveredPipeTaskInfo | ||
| .getPipeMetaByPipeName(consensusPipeStoppedByException) | ||
| .getRuntimeMeta() | ||
| .getStatus() | ||
| .get()); | ||
| Assert.assertTrue( | ||
| recoveredPipeTaskInfo | ||
| .getPipeMetaByPipeName(consensusPipeStoppedByException) | ||
| .getRuntimeMeta() | ||
| .getIsStoppedByRuntimeException()); | ||
| Assert.assertEquals( | ||
| PipeStatus.STOPPED, | ||
| recoveredPipeTaskInfo | ||
| .getPipeMetaByPipeName(userPipeName) | ||
| .getRuntimeMeta() | ||
| .getStatus() | ||
| .get()); | ||
| } finally { | ||
| new File(snapshotDir, "pipe_task_info.bin").delete(); | ||
| snapshotDir.delete(); | ||
| } | ||
|
Comment on lines
+204
to
+207
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
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.