Skip to content

[FLINK-34251][core] Improve diagnostics for closure serialization failures - #29230

Open
liuml07 wants to merge 2 commits into
apache:masterfrom
liuml07:FLINK-34251
Open

liuml07 wants to merge 2 commits into
apache:masterfrom
liuml07:FLINK-34251

Conversation

@liuml07

@liuml07 liuml07 commented Sep 17, 2026

Copy link
Copy Markdown
Member

This supersedes #26776, which was automatically closed as stale, and the earlier #24205.

JIRA: https://issues.apache.org/jira/browse/FLINK-34251

What is the purpose of the change

ClosureCleaner reports the nested non-serializable object, but complex jobs may reference that object through several operators and third-party classes. The current exception does not show how the object is reached.

This change adds the traversed field path to the exception using the established Java/Spark serialization-debugging format, for example:

java.lang.Object@... is not serializable.
Reference path:
    - object not serializable (class: java.lang.Object)
    - field (class: com.mycompany.LocalMap, name: delegate, type: class java.lang.Object)
    - field (class: com.mycompany.ComplexMap, name: map4, type: class com.mycompany.LocalMap)

Brief change log

  • Track fields while recursively cleaning nested objects.
  • Report the offending class and each field's declaring class, name, and type, from leaf to root.
  • Restore the diagnostic path reliably when recursive cleaning exits.
  • Add coverage in ClosureCleanerTest.

Verifying this change

ClosureCleanerTest covers the nested failure and validates the ordered class-and-field path. All 16 tests in the class pass with Java 17. Checkstyle and Java formatting checks pass for the changed files.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Pi 0.85.1

Track field names alongside classes while traversing nested non-serializable objects, and keep the diagnostic path balanced when recursive cleaning fails.

Generated-by: Pi 0.85.1
@flinkbot

flinkbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants