You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "liuml07 (via GitHub)" <gi...@apache.org> on 2024/01/27 05:29:31 UTC

[PR] [FLINK-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

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

   
   <!--
   *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
   
   Currently the ClosureCleaner throws exception if {{checkSerializable} is enabled while some object is non-serializable. It includes the non-serializable (nested) object in the exception in the exception message.
   
   However, when the user job program gets more complex pulling multiple operators each of which pulls multiple 3rd party libraries, it is unclear how the non-serializable object is referenced as some of those objects could be nested in multiple levels. For example, following exception is not straightforward where to check:
   ```
   org.apache.flink.api.common.InvalidProgramException: java.lang.Object@528c868 is not serializable. 
   ```
   
   It would be nice to include the reference stack in the exception message, as following:
   ```
   org.apache.flink.api.common.InvalidProgramException: java.lang.Object@72437d8d is not serializable. Referenced via [class com.mycompany.myapp.ComplexMap, class com.mycompany.myapp.LocalMap, class com.yourcompany.yourapp.YourPojo, class com.hercompany.herapp.Random, class java.lang.Object] ...
   ```
   
   ## Verifying this change
   
   This change is largely covered by existing tests, and new test case was added to `ClosureCleanerTest`.
   
   ## 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)
   


-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #24205: [FLINK-34251][core] ClosureCleaner to include reference classes for non-serialization exception
URL: https://github.com/apache/flink/pull/24205


-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

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

   @sujay-jain Could you help review this patch? I think you have context about potential use cases that can benefit from it. Thanks!


-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "154e41a43c45a2bb59f0b1a4af37e7652434f8b7",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "154e41a43c45a2bb59f0b1a4af37e7652434f8b7",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 154e41a43c45a2bb59f0b1a4af37e7652434f8b7 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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

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

   @zentol Could you take 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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

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


##########
flink-core/src/main/java/org/apache/flink/api/java/ClosureCleaner.java:
##########
@@ -66,14 +67,20 @@ public class ClosureCleaner {
      */
     public static void clean(
             Object func, ExecutionConfig.ClosureCleanerLevel level, boolean checkSerializable) {
-        clean(func, level, checkSerializable, Collections.newSetFromMap(new IdentityHashMap<>()));
+        clean(
+                func,
+                level,
+                checkSerializable,
+                Collections.newSetFromMap(new IdentityHashMap<>()),
+                new Stack<>());
     }
 
     private static void clean(
             Object func,
             ExecutionConfig.ClosureCleanerLevel level,
             boolean checkSerializable,
-            Set<Object> visited) {
+            Set<Object> visited,
+            Stack<Class<?>> clsReferences) {

Review Comment:
   The stack is not growing when there is circular references or self-references as there is a `visited` Set already to only visit a class once.



-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

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


##########
flink-core/src/test/java/org/apache/flink/api/java/ClosureCleanerTest.java:
##########
@@ -133,6 +135,27 @@ void testComplexTopLevelClassClean() throws Exception {
         assertThat(result).isEqualTo(5);
     }
 
+    @Test
+    public void testCleanNonSerializableNestedMap() throws Exception {

Review Comment:
   There are multiple classes here in the test: `ComplexMap` has `map1` field which is a `MapFunction`. This MapFunction refers to a non-serializable Object. Meanwhile `ComplexMap` also has `map4` field  which is a `LocalMap`. This LocalMap also refers to same value of `map1`. So it has 4 layers of references.



-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24205:
URL: https://github.com/apache/flink/pull/24205#issuecomment-2954778569

   This PR has been closed since it has not had any activity in 120 days. 
   If you feel like this was a mistake, or you would like to continue working on it, 
   please feel free to re-open the PR and ask for a review.


-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24205:
URL: https://github.com/apache/flink/pull/24205#issuecomment-2868493421

   This PR is being marked as stale since it has not had any activity in the last 90 days. 
   If you would like to keep this PR alive, please leave a comment asking for a review. 
   If the PR has merge conflicts, update it with the latest from the base branch.
   
   If you are having difficulty finding a reviewer, please reach out to the 
   community, contact details can be found here: https://flink.apache.org/what-is-flink/community/
   
   If this PR is no longer valid or desired, please feel free to close it. 
   If no activity occurs in the next 30 days, it will be automatically closed.


-- 
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-34251][core] ClosureCleaner to include reference classes for non-serialization exception [flink]

Posted by "sujay-jain (via GitHub)" <gi...@apache.org>.
sujay-jain commented on code in PR #24205:
URL: https://github.com/apache/flink/pull/24205#discussion_r1947967477


##########
flink-core/src/main/java/org/apache/flink/api/java/ClosureCleaner.java:
##########
@@ -66,14 +67,20 @@ public class ClosureCleaner {
      */
     public static void clean(
             Object func, ExecutionConfig.ClosureCleanerLevel level, boolean checkSerializable) {
-        clean(func, level, checkSerializable, Collections.newSetFromMap(new IdentityHashMap<>()));
+        clean(
+                func,
+                level,
+                checkSerializable,
+                Collections.newSetFromMap(new IdentityHashMap<>()),
+                new Stack<>());
     }
 
     private static void clean(
             Object func,
             ExecutionConfig.ClosureCleanerLevel level,
             boolean checkSerializable,
-            Set<Object> visited) {
+            Set<Object> visited,
+            Stack<Class<?>> clsReferences) {

Review Comment:
   Do you see any risk of excessive stack growth in case of complex or deep reference graphs?



##########
flink-core/src/test/java/org/apache/flink/api/java/ClosureCleanerTest.java:
##########
@@ -133,6 +135,27 @@ void testComplexTopLevelClassClean() throws Exception {
         assertThat(result).isEqualTo(5);
     }
 
+    @Test
+    public void testCleanNonSerializableNestedMap() throws Exception {

Review Comment:
   Thanks for adding this test. Could you please add another test covering a scenario where multiple reference classes are involved?



-- 
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