Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ public void completeRestoration(final java.util.function.Consumer<Set<TopicParti
processorContext.initialize();
if (!eosEnabled) {
maybeCheckpoint(true);
} else {
// Deleting checkpoint file written during restoration before transition to RUNNING state (KAFKA-20685)
try {
stateMgr.deleteCheckPointFileIfEOSEnabled();
log.debug("Deleted check point file upon completing restoration with EOS enabled");
} catch (final IOException ioe) {
log.error("Encountered error while deleting the checkpoint file upon completing restoration", ioe);
}
}

transitionTo(State.RUNNING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3057,6 +3057,40 @@ public void shouldNotCheckpointAfterRestorationWhenExactlyOnceEnabled() {
verify(recordCollector, never()).offsets();
}

@Test
public void shouldDeleteCheckpointFileAfterRestorationWhenExactlyOnceEnabled() throws IOException {
final ProcessorStateManager processorStateManager = mockStateManager();
recordCollector = mock(RecordCollectorImpl.class);

task = createStatefulTask(createConfig(EXACTLY_ONCE_V2, "100"), true, processorStateManager);
task.initializeIfNeeded();
task.completeRestoration(noOpResetter -> { });
verify(processorStateManager).deleteCheckPointFileIfEOSEnabled();
}

@Test
public void shouldNotDeleteCheckpointFileAfterRestorationWhenAtLeastOnceEnabled() throws IOException {
final ProcessorStateManager processorStateManager = mockStateManager();
recordCollector = mock(RecordCollectorImpl.class);

task = createStatefulTask(createConfig(AT_LEAST_ONCE, "100"), true, processorStateManager);
task.initializeIfNeeded();
task.completeRestoration(noOpResetter -> { });
verify(processorStateManager, never()).deleteCheckPointFileIfEOSEnabled();
}

@Test
public void shouldStillCompleteRestorationWhenCheckpointFileDeletionFails() throws IOException {
final ProcessorStateManager processorStateManager = mockStateManager();
recordCollector = mock(RecordCollectorImpl.class);
doThrow(new IOException("KABOOM!")).when(processorStateManager).deleteCheckPointFileIfEOSEnabled();

task = createStatefulTask(createConfig(EXACTLY_ONCE_V2, "100"), true, processorStateManager);
task.initializeIfNeeded();
task.completeRestoration(noOpResetter -> { });
assertEquals(RUNNING, task.state());
}

@Test
public void punctuateShouldNotHandleFailProcessingExceptionAndThrowStreamsException() {
when(stateManager.taskId()).thenReturn(taskId);
Expand Down