Skip to content

Conversation

@shashankhs11
Copy link
Contributor

Handle TimeoutException in StateUpdater code path in TaskManager.java

Reviewers: Lucas Brutschy [email protected]

@github-actions github-actions bot added triage PRs from the community streams small Small PRs labels Nov 5, 2025
@shashankhs11 shashankhs11 changed the title KAFKA-19684: Handle TimeoutException from initializeIfNeeded() in StateUpdater Code KAFKA-19864: Handle TimeoutException from initializeIfNeeded() in StateUpdater Code Nov 5, 2025
for (final StreamTask restoredTask : restoredTasks) {
verify(restoredTask).completeRestoration(noOpResetter);
verify(restoredTask).clearTaskTimeout();
verify(restoredTask, atLeastOnce()).clearTaskTimeout();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this because, one of the tests shouldAddNewActiveTasks was failing as it expected the call to clearTaskTimeout() more than once.

@github-actions github-actions bot removed the triage PRs from the community label Nov 5, 2025
@lucasbru lucasbru requested a review from Copilot November 5, 2025 11:20
@lucasbru lucasbru self-requested a review November 5, 2025 11:20
Copy link
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 adds handling for TimeoutException during task initialization in the state updater, aligning its behavior with existing LockException handling. It also ensures that task timeouts are properly cleared after successful initialization.

Key changes:

  • Added a TimeoutException catch block in addTaskToStateUpdater that retries initialization with backoff
  • Added clearTaskTimeout() call after successful task initialization
  • Updated tests to verify timeout handling behavior and clearTaskTimeout invocation

Reviewed Changes

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

File Description
TaskManager.java Added TimeoutException handling with retry logic and clearTaskTimeout call after successful initialization
TaskManagerTest.java Added test for TimeoutException during initialization and updated existing tests to verify clearTaskTimeout behavior
Comments suppressed due to low confidence (1)

streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java:1160

  • The test shouldAddTasksToStateUpdater should verify that clearTaskTimeout() is called on both tasks after successful initialization, consistent with the new behavior added in line 1085 of TaskManager.java and verified in other tests like shouldRetryInitializationWhenLockExceptionInStateUpdater.
        verify(task00).initializeIfNeeded();
        verify(task01).initializeIfNeeded();
        verify(stateUpdater).add(task00);
        verify(stateUpdater).add(task01);

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant