You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by dianfu <gi...@git.apache.org> on 2017/12/09 03:01:17 UTC

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

GitHub user dianfu opened a pull request:

    https://github.com/apache/flink/pull/5141

    [FLINK-8226] [cep] Dangling reference generated after NFA clean up timed out SharedBufferEntry

    …med out SharedBufferEntry
    
    
    *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.*
    
    ## What is the purpose of the change
    
    *(For example: This pull request fix the issue that dangling reference generated after NFA clean up timed out SharedBufferEntry. Exception will be thrown when serializing NFA.*
    
    
    ## Verifying this change
    
    This change added tests and can be verified as follows:
    
    *(example:)*
      - *Added tests NFATest#testTimeoutWindowPruning2*
    
    ## 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, Yarn/Mesos, 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)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dianfu/flink dangling_ref

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/5141.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #5141
    
----
commit 982bfafaabcfbfd78f4fcbdd9438eab9c8be65bb
Author: Dian Fu <fu...@alibaba-inc.com>
Date:   2017-12-09T02:55:14Z

    [FLINK-8226] [cep] Dangling reference generated after NFA clean up timed out SharedBufferEntry

----


---

[GitHub] flink issue #5141: [FLINK-8226] [cep] Dangling reference generated after NFA...

Posted by dianfu <gi...@git.apache.org>.
Github user dianfu commented on the issue:

    https://github.com/apache/flink/pull/5141
  
    @dawidwys  Could you help to take a look at this PR? This is a bug fix and the issue can be easily reproduced with the test case included in the PR. Thanks a lot.


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dawidwys <gi...@git.apache.org>.
Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r159057128
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -191,22 +191,28 @@ public boolean isEmpty() {
     	 */
     	public boolean prune(long pruningTimestamp) {
     		Iterator<Map.Entry<K, SharedBufferPage<K, V>>> iter = pages.entrySet().iterator();
    -		boolean pruned = false;
    +		List<SharedBufferEntry<K, V>> prunedEntries = new ArrayList<>();
     
     		while (iter.hasNext()) {
     			SharedBufferPage<K, V> page = iter.next().getValue();
     
    -			if (page.prune(pruningTimestamp)) {
    -				pruned = true;
    -			}
    +			page.prune(pruningTimestamp, prunedEntries);
     
     			if (page.isEmpty()) {
     				// delete page if it is empty
     				iter.remove();
     			}
     		}
     
    -		return pruned;
    +		if (!prunedEntries.isEmpty()) {
    +			for (Map.Entry<K, SharedBufferPage<K, V>> entry : pages.entrySet()) {
    +				entry.getValue().removeEdges(prunedEntries);
    +			}
    +			prunedEntries.clear();
    --- End diff --
    
    As prunedEntries is local now, you don't need to clear it any longer.


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dianfu <gi...@git.apache.org>.
Github user dianfu commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r158908615
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -82,9 +82,12 @@
     
     	private transient Map<K, SharedBufferPage<K, V>> pages;
     
    +	private final transient List<SharedBufferEntry<K, V>> prunedEntries;
    --- End diff --
    
    Make sense, I will change it to local variable.


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dianfu <gi...@git.apache.org>.
Github user dianfu commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r159149194
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -191,22 +191,28 @@ public boolean isEmpty() {
     	 */
     	public boolean prune(long pruningTimestamp) {
     		Iterator<Map.Entry<K, SharedBufferPage<K, V>>> iter = pages.entrySet().iterator();
    -		boolean pruned = false;
    +		List<SharedBufferEntry<K, V>> prunedEntries = new ArrayList<>();
     
     		while (iter.hasNext()) {
     			SharedBufferPage<K, V> page = iter.next().getValue();
     
    -			if (page.prune(pruningTimestamp)) {
    -				pruned = true;
    -			}
    +			page.prune(pruningTimestamp, prunedEntries);
     
     			if (page.isEmpty()) {
     				// delete page if it is empty
     				iter.remove();
     			}
     		}
     
    -		return pruned;
    +		if (!prunedEntries.isEmpty()) {
    +			for (Map.Entry<K, SharedBufferPage<K, V>> entry : pages.entrySet()) {
    +				entry.getValue().removeEdges(prunedEntries);
    +			}
    +			prunedEntries.clear();
    --- End diff --
    
    Updated.


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dawidwys <gi...@git.apache.org>.
Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r158908424
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -82,9 +82,12 @@
     
     	private transient Map<K, SharedBufferPage<K, V>> pages;
     
    +	private final transient List<SharedBufferEntry<K, V>> prunedEntries;
    --- End diff --
    
    Not sure about the potential advantages. See e.g. this answer on SO: https://stackoverflow.com/a/18371813/4250114 . Plus the local variable is easier to reason about.
    
    Personally I am for the local variable, but if you feel this version is better, will merge it as it is.


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dawidwys <gi...@git.apache.org>.
Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r158811709
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -82,9 +82,12 @@
     
     	private transient Map<K, SharedBufferPage<K, V>> pages;
     
    +	private final transient List<SharedBufferEntry<K, V>> prunedEntries;
    --- End diff --
    
    Is it necessary for it to be a field? Isn't a local variable sufficient?


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/5141


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dianfu <gi...@git.apache.org>.
Github user dianfu commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r158909117
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -82,9 +82,12 @@
     
     	private transient Map<K, SharedBufferPage<K, V>> pages;
     
    +	private final transient List<SharedBufferEntry<K, V>> prunedEntries;
    --- End diff --
    
    Updated the PR. Thanks a lot for the review. :)


---

[GitHub] flink pull request #5141: [FLINK-8226] [cep] Dangling reference generated af...

Posted by dianfu <gi...@git.apache.org>.
Github user dianfu commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5141#discussion_r158888833
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/SharedBuffer.java ---
    @@ -82,9 +82,12 @@
     
     	private transient Map<K, SharedBufferPage<K, V>> pages;
     
    +	private final transient List<SharedBufferEntry<K, V>> prunedEntries;
    --- End diff --
    
    It is for object reuse. What's your thought?


---