[ 
https://issues.apache.org/jira/browse/KAFKA-21549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matthias J. Sax updated KAFKA-21549:
------------------------------------
    Description: 
Paused tasks stay registered in StoreChangelogReader#changelogs, but restore() 
only receives the updating tasks. maybeUpdateLimitOffsetsForStandbyChangelogs() 
picks its partitions from all registered changelogs, including those of paused 
standby tasks:
{code:java}
final Set<TopicPartition> changelogsWithLimitOffsets = 
changelogs.entrySet().stream().filter(
    entry -> entry.getValue().stateManager.taskType() == Task.TaskType.STANDBY 
&&
    entry.getValue().stateManager.changelogAsSource(entry.getKey()))
  .map(Map.Entry::getKey).collect(Collectors.toSet());
{code}
If listConsumerGroupOffsets() fails with a retriable exception, 
committedOffsetForChangelogs() calls getTasksFromPartitions(). For a paused 
task, tasks.get() returns null, so null ends up in the task set, and 
maybeInitTaskTimeoutOrThrow() dereferences it:
{code:java}
tasks.forEach(t -> t.maybeInitTaskTimeoutOrThrow(now, cause));  {code}
clearTaskTimeout() guards against null, but maybeInitTaskTimeoutOrThrow() does 
not. The NullPointerException kills the state updater thread. 

changelogsWithLimitOffsets should only contain changelogs of tasks in tasks, 
the same check fetchableChangelogs() makes.

  was:
Paused tasks stay registered in StoreChangelogReader#changelogs, but restore() 
only receives the updating tasks. maybeUpdateLimitOffsetsForStandbyChangelogs() 
picks its partitions from all registered changelogs, including those of paused 
standby tasks:

 
{code:java}
final Set<TopicPartition> changelogsWithLimitOffsets = 
changelogs.entrySet().stream().filter(
    entry -> entry.getValue().stateManager.taskType() == Task.TaskType.STANDBY 
&&
    entry.getValue().stateManager.changelogAsSource(entry.getKey()))
  .map(Map.Entry::getKey).collect(Collectors.toSet());
{code}
 

If listConsumerGroupOffsets() fails with a retriable exception, 
committedOffsetForChangelogs() calls getTasksFromPartitions(). For a paused 
task, tasks.get() returns null, so null ends up in the task set, and 
maybeInitTaskTimeoutOrThrow() dereferences it:

 
{code:java}
tasks.forEach(t -> t.maybeInitTaskTimeoutOrThrow(now, cause));  {code}
 

clearTaskTimeout() guards against null, but maybeInitTaskTimeoutOrThrow() does 
not. The NullPointerException kills the state updater thread. 

changelogsWithLimitOffsets should only contain changelogs of tasks in tasks, 
the same check fetchableChangelogs() makes.


> StoreChangelogReader throws NullPointerException for a paused standby task 
> when committed offsets cannot be fetched
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-21549
>                 URL: https://issues.apache.org/jira/browse/KAFKA-21549
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>    Affects Versions: 3.8.0
>            Reporter: Matthias J. Sax
>            Assignee: Lucas Brutschy
>            Priority: Minor
>
> Paused tasks stay registered in StoreChangelogReader#changelogs, but 
> restore() only receives the updating tasks. 
> maybeUpdateLimitOffsetsForStandbyChangelogs() picks its partitions from all 
> registered changelogs, including those of paused standby tasks:
> {code:java}
> final Set<TopicPartition> changelogsWithLimitOffsets = 
> changelogs.entrySet().stream().filter(
>     entry -> entry.getValue().stateManager.taskType() == 
> Task.TaskType.STANDBY &&
>     entry.getValue().stateManager.changelogAsSource(entry.getKey()))
>   .map(Map.Entry::getKey).collect(Collectors.toSet());
> {code}
> If listConsumerGroupOffsets() fails with a retriable exception, 
> committedOffsetForChangelogs() calls getTasksFromPartitions(). For a paused 
> task, tasks.get() returns null, so null ends up in the task set, and 
> maybeInitTaskTimeoutOrThrow() dereferences it:
> {code:java}
> tasks.forEach(t -> t.maybeInitTaskTimeoutOrThrow(now, cause));  {code}
> clearTaskTimeout() guards against null, but maybeInitTaskTimeoutOrThrow() 
> does not. The NullPointerException kills the state updater thread. 
> changelogsWithLimitOffsets should only contain changelogs of tasks in tasks, 
> the same check fetchableChangelogs() makes.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to