Skip to content

Conversation

@ayalamark-afk
Copy link

@ayalamark-afk ayalamark-afk commented Jan 29, 2026

Summary

Fix for KAFKA-17676 - NullPointerException when starting tasks after the connect-configs topic has been compacted.

Problem

When the connect-configs topic gets compacted, two scenarios can cause NPE crashes:

  1. Incomplete task configs due to compaction: Task config records get compacted leaving an incomplete set, but connectorTaskCounts is still updated, causing NPE when trying to start tasks without configs.

  2. Missing connector config: Connector config records can be removed by compaction even though the connector is still active. The fix for KAFKA-16838 assumes that if a connector config is missing, the connector was deleted, and ignores task configs. This causes an NPE when trying to start tasks:

java.lang.NullPointerException: Cannot invoke "java.util.Map.size()" because "inputMap" is null
at org.apache.kafka.connect.runtime.TaskConfig.
at org.apache.kafka.connect.runtime.Worker.startTask

Solution

Two fixes in processTasksCommitRecord:

Fix 1: Only update connectorTaskCounts when we actually apply task configs

  • Moves connectorTaskCounts.put() inside the else block
  • Prevents advertising task count without having configs for all tasks

Fix 2: Handle compacted connector configs gracefully

  • Distinguish between truly deleted connector (no deferred updates, not previously applied) vs compacted config
  • Recover from previously applied config if available
  • Mark as inconsistent if recovery not possible (preserves KAFKA-16838 fix behavior)

Both fixes are needed to fully address NPE crashes when starting tasks after config topic compaction.

@github-actions github-actions bot added triage PRs from the community connect small Small PRs labels Jan 29, 2026
This commit includes two fixes for NPE issues caused by config topic compaction:

Fix 1: Only update connectorTaskCounts when we actually apply task configs
- Moves connectorTaskCounts.put() inside the else block
- Prevents advertising task count without having configs for all tasks
- Handles incomplete task set scenario due to compaction

Fix 2: Handle compacted connector configs gracefully
- Distinguish between deleted connector vs compacted config
- Recover from previously applied config if available
- Mark as inconsistent if recovery not possible

Both fixes are needed to fully address NPE crashes when starting tasks
after the connect-configs topic has been compacted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connect small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant