You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Izeren (via GitHub)" <gi...@apache.org> on 2026/07/31 10:32:02 UTC

[PR] Flink 40208/job mdc registry [flink]

Izeren opened a new pull request, #28855:
URL: https://github.com/apache/flink/pull/28855

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
   
   
   ## Brief change log
   
   *(for example:)*
     - *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
     - *Deployments RPC transmits only the blob storage reference*
     - *TaskManagers retrieve the TaskInfo from the blob cache*
   
   
   ## Verifying this change
   
   Please make sure both new and modified tests in this PR follow [the conventions for tests defined in our code quality guide](https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#7-testing).
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (100MB)*
     - *Extended integration test for recovery after master (JobManager) failure*
     - *Added test that validates that TaskInfo is transferred only once across recoveries*
     - *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change the checkbox below to `[X]` and replace the placeholder in the "Generated-by"
   line with the tool name and version. Otherwise remove the "Generated-by" line.
   See the ASF Generative Tooling Guidance for details:
   https://www.apache.org/legal/generative-tooling.html
   
   You are responsible for the quality and correctness of every change in this PR
   regardless of the tooling used. Low-effort AI-generated PRs will be closed. See
   AGENTS.md for the full guidance.
   -->
   
   - [ ] Yes (please specify the tool below)
   
   Generated-by: [Tool Name and Version]
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on code in PR #28855:
URL: https://github.com/apache/flink/pull/28855#discussion_r3704075871


##########
flink-core/src/main/java/org/apache/flink/util/MdcUtils.java:
##########
@@ -112,7 +115,38 @@ public static ScheduledExecutorService scopeToJob(JobID jobID, ScheduledExecutor
         return new MdcAwareScheduledExecutorService(ses, asContextData(jobID));
     }
 
+    /**
+     * Build MDC context for a job. Consults the {@link JobMdcRegistry} for enriched context
+     * registered where the job {@link Configuration} is available; falls back to the plain job ID
+     * entry.
+     */
     public static Map<String, String> asContextData(JobID jobID) {
+        final Map<String, String> registered = JobMdcRegistry.lookup(jobID);
+        if (registered != null) {
+            return registered;
+        }
         return Collections.singletonMap(JOB_ID, jobID.toHexString());
     }
+
+    /**
+     * Build MDC context from a job ID and job configuration, enriching with context entries
+     * configured via {@link MdcOptions#JOB_CONFIGURATION_TO_MDC_KEYS}.
+     */
+    public static Map<String, String> asContextData(
+            final JobID jobID, final Configuration jobConfiguration) {
+        final Map<String, String> mdcKeyMapping =
+                jobConfiguration.get(MdcOptions.JOB_CONFIGURATION_TO_MDC_KEYS);
+        final Map<String, String> context = new HashMap<>();
+        for (Map.Entry<String, String> entry : mdcKeyMapping.entrySet()) {
+            final String value = jobConfiguration.getString(entry.getKey(), null);
+            if (value != null && !value.isBlank()) {
+                context.put(entry.getValue(), value);

Review Comment:
   The asymmetry here comes from the fact that `key` maybe empty until upstream service submitting the job is not providing the value in config. Key side acts as a "switch" for configs that we might expect. Empty value though would be a deliberate misconfiguration. So I'd not complicate the code here with extra check



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on code in PR #28855:
URL: https://github.com/apache/flink/pull/28855#discussion_r3704109317


##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java:
##########
@@ -2078,6 +2084,7 @@ private void releaseJobResources(JobID jobId, Exception cause) {
         taskInformationCache.clearCacheForGroup(jobId);
         shuffleDescriptorsCache.clearCacheForGroup(jobId);
         fileMergingManager.releaseMergingSnapshotManagerForJob(jobId);
+        JobMdcRegistry.unregister(jobId);

Review Comment:
   Will have a look



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on PR #28855:
URL: https://github.com/apache/flink/pull/28855#issuecomment-5177238601

   @wenshao, I have added a new PR with some of the follow ups: https://github.com/apache/flink/pull/28917


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on code in PR #28855:
URL: https://github.com/apache/flink/pull/28855#discussion_r3704058472


##########
docs/content/docs/ops/logging_context.md:
##########
@@ -0,0 +1,86 @@
+---
+title: "Logging Context (MDC)"
+weight: 7
+type: docs

Review Comment:
   This looks minor, but I might include it if I do any more cleanup



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on code in PR #28855:
URL: https://github.com/apache/flink/pull/28855#discussion_r3704097264


##########
flink-core/src/main/java/org/apache/flink/util/JobMdcRegistry.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.util;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.configuration.Configuration;
+
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.ThreadSafe;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Process-wide registry mapping {@link JobID} to enriched MDC context, populated where the job
+ * {@link Configuration} is available and consulted by {@link MdcUtils#asContextData(JobID)}.
+ */
+@Internal
+@ThreadSafe
+public final class JobMdcRegistry {
+
+    private static final Map<JobID, Map<String, String>> REGISTRY = new ConcurrentHashMap<>();
+
+    private JobMdcRegistry() {}
+
+    /**
+     * Registers enriched MDC context if the configuration carries any MDC key mappings; clears any
+     * stale entry otherwise. Equivalent to {@link #unregister} when the config is unenriched.
+     */
+    public static void registerOrClear(final JobID jobID, final Configuration jobConfiguration) {
+        final Map<String, String> context = MdcUtils.asContextData(jobID, jobConfiguration);
+        if (context.size() > 1) {
+            REGISTRY.put(jobID, context);
+        } else {
+            unregister(jobID);
+        }

Review Comment:
   Debug logs are normally not enabled in prod. Presence of the field is a signal on its own to confirm whether the feature is working. More realistic scenario is an alert setup for "missing" field and oncall engineer checking what has changed that led to field disappearing (and end to end tests, to catch such regressions before prod)



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "rkhachatryan (via GitHub)" <gi...@apache.org>.
rkhachatryan merged PR #28855:
URL: https://github.com/apache/flink/pull/28855


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on PR #28855:
URL: https://github.com/apache/flink/pull/28855#issuecomment-5143209152

   @rkhachatryan, thank you for the review before. This time CI is green


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "Izeren (via GitHub)" <gi...@apache.org>.
Izeren commented on code in PR #28855:
URL: https://github.com/apache/flink/pull/28855#discussion_r3704106832


##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java:
##########
@@ -661,9 +662,20 @@ public CompletableFuture<Acknowledge> submitTask(
             TaskDeploymentDescriptor tdd, JobMasterId jobMasterId, Duration timeout) {
 
         final JobID jobId = tdd.getJobId();
-        // todo: consider adding task info
-        try (MdcCloseable ignored = MdcUtils.withContext(MdcUtils.asContextData(jobId))) {
-
+        JobInformation jobInformation = null;
+        try {
+            jobInformation = tdd.getJobInformation();
+        } catch (IllegalStateException ignored) {
+            // Expected when job information is offloaded to blob storage and not yet loaded.

Review Comment:
   Will have a look



##########
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java:
##########
@@ -572,6 +573,7 @@ private void runRecoveredJob(
         initJobClientExpiredTime(recoveredJob);
 
         final JobID jobId = recoveredJob.getJobID();
+        JobMdcRegistry.registerOrClear(jobId, recoveredJob.getJobConfiguration());
         try (MdcCloseable ignored = MdcUtils.withContext(MdcUtils.asContextData(jobId))) {

Review Comment:
   Will have a look



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "wenshao (via GitHub)" <gi...@apache.org>.
wenshao commented on code in PR #28855:
URL: https://github.com/apache/flink/pull/28855#discussion_r3696500725


##########
docs/content/docs/ops/logging_context.md:
##########
@@ -0,0 +1,86 @@
+---
+title: "Logging Context (MDC)"
+weight: 7
+type: docs

Review Comment:
   **[Suggestion]** Hugo `weight: 7` collides with sibling `docs/content/docs/ops/events.md` (also `weight: 7`), making their nav ordering non-deterministic. — Concrete cost: Hugo falls back to alphabetical tie-breaking between "Events" and "Logging Context (MDC)", so the sidebar position becomes an accident of the title rather than an editorial choice. The same collision exists in `docs/content.zh/docs/ops/logging_context.md`.
   
   ```suggestion
   title: "Logging Context (MDC)"
   weight: 8
   type: docs
   ```
   
   _— qwen3.8-max-preview via Qwen Code /review (v0.21.2)_



##########
flink-core/src/main/java/org/apache/flink/util/MdcUtils.java:
##########
@@ -112,7 +115,38 @@ public static ScheduledExecutorService scopeToJob(JobID jobID, ScheduledExecutor
         return new MdcAwareScheduledExecutorService(ses, asContextData(jobID));
     }
 
+    /**
+     * Build MDC context for a job. Consults the {@link JobMdcRegistry} for enriched context
+     * registered where the job {@link Configuration} is available; falls back to the plain job ID
+     * entry.
+     */
     public static Map<String, String> asContextData(JobID jobID) {
+        final Map<String, String> registered = JobMdcRegistry.lookup(jobID);
+        if (registered != null) {
+            return registered;
+        }
         return Collections.singletonMap(JOB_ID, jobID.toHexString());
     }
+
+    /**
+     * Build MDC context from a job ID and job configuration, enriching with context entries
+     * configured via {@link MdcOptions#JOB_CONFIGURATION_TO_MDC_KEYS}.
+     */
+    public static Map<String, String> asContextData(
+            final JobID jobID, final Configuration jobConfiguration) {
+        final Map<String, String> mdcKeyMapping =
+                jobConfiguration.get(MdcOptions.JOB_CONFIGURATION_TO_MDC_KEYS);
+        final Map<String, String> context = new HashMap<>();
+        for (Map.Entry<String, String> entry : mdcKeyMapping.entrySet()) {
+            final String value = jobConfiguration.getString(entry.getKey(), null);
+            if (value != null && !value.isBlank()) {
+                context.put(entry.getValue(), value);

Review Comment:
   **[Suggestion]** The mapping target (MDC key name, `entry.getValue()`) is not validated for blank/empty, while the mapping source value is explicitly checked for blankness — an asymmetry that allows an empty or whitespace-only MDC key to be published. — Failure scenario: an operator configures `mdc.job-configuration-to-mdc-keys: {my.key: ""}` in `config.yaml`. The code puts an entry with an empty-string key into the context map, which is then set on every thread's MDC for that job. In Log4j2 JSON layout this produces `"": "some-value"` in every log record; in pattern layout, `%X{}` with an empty key has implementation-dependent behavior.
   
   ```suggestion
   			for (Map.Entry<String, String> entry : mdcKeyMapping.entrySet()) {
   				final String value = jobConfiguration.getString(entry.getKey(), null);
   				final String mdcKey = entry.getValue();
   				if (value != null && !value.isBlank() && mdcKey != null && !mdcKey.isBlank()) {
   					context.put(mdcKey, value);
   ```
   
   _— qwen3.8-max-preview via Qwen Code /review (v0.21.2)_



##########
flink-core/src/main/java/org/apache/flink/util/JobMdcRegistry.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.util;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.configuration.Configuration;
+
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.ThreadSafe;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Process-wide registry mapping {@link JobID} to enriched MDC context, populated where the job
+ * {@link Configuration} is available and consulted by {@link MdcUtils#asContextData(JobID)}.
+ */
+@Internal
+@ThreadSafe
+public final class JobMdcRegistry {
+
+    private static final Map<JobID, Map<String, String>> REGISTRY = new ConcurrentHashMap<>();
+
+    private JobMdcRegistry() {}
+
+    /**
+     * Registers enriched MDC context if the configuration carries any MDC key mappings; clears any
+     * stale entry otherwise. Equivalent to {@link #unregister} when the config is unenriched.
+     */
+    public static void registerOrClear(final JobID jobID, final Configuration jobConfiguration) {
+        final Map<String, String> context = MdcUtils.asContextData(jobID, jobConfiguration);
+        if (context.size() > 1) {
+            REGISTRY.put(jobID, context);
+        } else {
+            unregister(jobID);
+        }

Review Comment:
   **[Suggestion]** No diagnostic logging at any level when MDC enrichment is configured but resolves to zero entries, making misconfiguration invisible at runtime. — Failure scenario: an operator configures `mdc.job-configuration-to-mdc-keys: pipeline.name: pipeline-name` but the job is submitted without `-Dpipeline.name=...`. Every mapped key is silently skipped, `registerOrClear` calls `unregister`, and all log records carry only `flink-job-id`. At 3 AM, the oncall engineer sees no error, no warning, and no debug message explaining why the expected `pipeline-name` field is absent from every log record.
   
   Consider adding a debug-level log that reports the configured mapping size and the resolved entry count, e.g.:
   ```java
   if (LOG.isDebugEnabled()) {
       LOG.debug("MDC enrichment for job {}: {} configured key(s), {} resolved entry(ies).",
           jobID, mdcKeyMapping.size(), context.size() - 1);
   }
   ```
   
   _— qwen3.8-max-preview via Qwen Code /review (v0.21.2)_



##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java:
##########
@@ -2078,6 +2084,7 @@ private void releaseJobResources(JobID jobId, Exception cause) {
         taskInformationCache.clearCacheForGroup(jobId);
         shuffleDescriptorsCache.clearCacheForGroup(jobId);
         fileMergingManager.releaseMergingSnapshotManagerForJob(jobId);
+        JobMdcRegistry.unregister(jobId);

Review Comment:
   **[Suggestion]** The TaskExecutor-side cleanup (`JobMdcRegistry.unregister` in the job release method) has no test; `TaskExecutorSubmissionTest` only verifies registration, not deregistration on release. — Failure scenario: if the `unregister` call were removed, every completed job's MDC entry would remain in the static `ConcurrentHashMap` for the lifetime of the TaskManager process. On a long-running TaskManager processing hundreds of short-lived jobs, this is an unbounded memory leak in a process-wide static registry. The Dispatcher-side cleanup is tested (`testJobMdcContextRegisteredOnSubmissionAndClearedOnTermination`), but the TM-side equivalent is not.
   
   _— qwen3.8-max-preview via Qwen Code /review (v0.21.2)_



##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java:
##########
@@ -661,9 +662,20 @@ public CompletableFuture<Acknowledge> submitTask(
             TaskDeploymentDescriptor tdd, JobMasterId jobMasterId, Duration timeout) {
 
         final JobID jobId = tdd.getJobId();
-        // todo: consider adding task info
-        try (MdcCloseable ignored = MdcUtils.withContext(MdcUtils.asContextData(jobId))) {
-
+        JobInformation jobInformation = null;
+        try {
+            jobInformation = tdd.getJobInformation();
+        } catch (IllegalStateException ignored) {
+            // Expected when job information is offloaded to blob storage and not yet loaded.

Review Comment:
   **[Suggestion]** The new early-deserialization fallback for offloaded job information (the `IllegalStateException` catch and the `jobInformation == null` ternary) has no test coverage. — Failure scenario: `TaskExecutorSubmissionTest.testJobMdcContextRegisteredOnSubmitTask` always constructs a TDD with inline job information, so `tdd.getJobInformation()` never throws `IllegalStateException`. If a future refactor removes the catch block or the null-guarded ternary, tasks with job information offloaded to blob storage (the production path for large job graphs) would fail submission with an unhandled `IllegalStateException`, and no test would catch the regression.
   
   _— qwen3.8-max-preview via Qwen Code /review (v0.21.2)_



##########
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java:
##########
@@ -572,6 +573,7 @@ private void runRecoveredJob(
         initJobClientExpiredTime(recoveredJob);
 
         final JobID jobId = recoveredJob.getJobID();
+        JobMdcRegistry.registerOrClear(jobId, recoveredJob.getJobConfiguration());
         try (MdcCloseable ignored = MdcUtils.withContext(MdcUtils.asContextData(jobId))) {

Review Comment:
   **[Suggestion]** The Dispatcher recovery path (`recoverJob`) MDC registration and its failure-path cleanup (`unregister` in the catch block) have no test coverage; `DispatcherTest` only tests the submission path. — Failure scenario: if the `registerOrClear` call in `recoverJob` were removed during a refactor, jobs recovered after a JobManager failover would silently lose enriched MDC context — all log lines for recovered jobs would carry only `flink-job-id` despite the job having MDC mappings configured. No existing test would fail.
   
   _— qwen3.8-max-preview via Qwen Code /review (v0.21.2)_



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Flink 40208/job mdc registry [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28855:
URL: https://github.com/apache/flink/pull/28855#issuecomment-5141994929

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "4e961af146ac40404870b3b422a20e9f6bdefafc",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "4e961af146ac40404870b3b422a20e9f6bdefafc",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 4e961af146ac40404870b3b422a20e9f6bdefafc UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment [flink]

Posted by "rkhachatryan (via GitHub)" <gi...@apache.org>.
rkhachatryan commented on PR #28855:
URL: https://github.com/apache/flink/pull/28855#issuecomment-5143561065

   Merged. 
   Thanks for the effort! 


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org