shwncho opened a new pull request, #356:
URL: https://github.com/apache/flink-connector-kafka/pull/356

   ## What is the purpose of the change
   
   `KafkaSource` keeps reading partitions that were removed from the 
subscription after a restore (see FLINK-41613). The only signal is `Discovered 
removed partitions: [...]`, logged at INFO on every partition discovery, and 
there is no metric to alert on. This pull request makes that state visible 
without changing which partitions are read.
   
   ## Brief change log
   
     - Add the gauge `KafkaSourceEnumerator.removedPartitions` 
(`...coordinator.enumerator.KafkaSourceEnumerator.removedPartitions`): the 
number of partitions that are assigned to readers but were not returned by the 
last partition discovery
     - Log `Discovered removed partitions` as WARN when the set changes and as 
DEBUG while it stays the same, instead of INFO on every discovery
     - Register the gauge in `KafkaSource#createEnumerator` and 
`#restoreEnumerator` through `KafkaSourceEnumerator#registerMetrics`, not in 
the constructor, because the dynamic Kafka source creates one enumerator per 
cluster on the same context
     - Document the metric in `docs/content` and `docs/content.zh`
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `KafkaSourceEnumeratorTest#testRemovedPartitionsGauge`: restores splits 
of two topics while subscribing to one, and checks that the gauge reports the 
partitions of the other topic after discovery and drops to 0 once they are 
discovered again. The test fails without the gauge update.
     - `KafkaSourceTest#testEnumeratorRegistersRemovedPartitionsGauge`: checks 
that both `createEnumerator` and `restoreEnumerator` register the gauge
   
   Locally on JDK 17: `./mvnw clean install -DskipTests` (checkstyle, spotless, 
RAT, japicmp, dependency analysis) and `./mvnw test -pl flink-connector-kafka` 
pass, except `YamlFileMetadataServiceTest`, which fails locally only because my 
checkout path contains non-ASCII characters and passes from an ASCII path. 
ITCases are left to CI.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency, including 
`kafka.version` or `flink.version`): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)` or `@Experimental`, or are the Table options or the PyFlink 
wrappers changed: no (`KafkaSourceEnumerator` is `@Internal`; adds a metric)
     - Checkpointed state, its serializers, or exactly-once delivery (splits, 
enumerator state, writer state, committables, transactions): no
     - The per-record code paths (split reader, record emitter, writer, 
serialization schemas; performance sensitive): no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? docs
     - If the docs changed, are both `docs/content` and `docs/content.zh` 
updated? yes
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 2.1.323 (Claude Opus 5.5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to