[
https://issues.apache.org/jira/browse/FLINK-8676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16367638#comment-16367638
]
ASF GitHub Bot commented on FLINK-8676:
---------------------------------------
GitHub user sihuazhou opened a pull request:
https://github.com/apache/flink/pull/5513
[FLINK-8676][state]
## What is the purpose of the change
This PR addressed issue
[FLINK-8676](https://issues.apache.org/jira/browse/FLINK-8676).
`AbstractKeyedStateBackend.applyToAllKeys() ` uses backend's
`getKeys(stateName, namespace)` to get all keys that belong to `namespace`.
But, in `RocksDBKeyedStateBackend.getKeys()` if just return a object which wrap
a `rocksdb iterator`, that is dangous, because rocksdb will ping the resources
that belong to the iterator into memory till `iterator.close()` is invoked, but
it wasn't invoked right now. This could lead to memory leak finally.
## Brief change log
- Ensure Stream.close() could be invoked to avoid memory leak.
## Verifying this change
This change is already covered by existing tests.
## 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)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sihuazhou/flink memory_leak_in_applyToAllKeys
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/5513.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 #5513
----
commit 70683f25b66b6f5d9320907ca31ffde0654129d5
Author: sihuazhou <summerleafs@...>
Date: 2018-02-16T17:31:18Z
Ensure Stream.close() could be invoked for avoid memory leak.
----
> Memory Leak in AbstractKeyedStateBackend.applyToAllKeys() when backend is
> base on RocksDB
> -----------------------------------------------------------------------------------------
>
> Key: FLINK-8676
> URL: https://issues.apache.org/jira/browse/FLINK-8676
> Project: Flink
> Issue Type: Bug
> Components: State Backends, Checkpointing, Streaming
> Affects Versions: 1.5.0
> Reporter: Sihua Zhou
> Assignee: Sihua Zhou
> Priority: Blocker
> Fix For: 1.5.0
>
>
> `AbstractKeyedStateBackend.applyToAllKeys() ` uses backend's
> getKeys(stateName, namespace) to get all keys that belong to `namespace`.
> But, in `RocksDBKeyedStateBackend.getKeys()` if just return a object which
> wrap a `rocksdb iterator`, that is dangous, because rocksdb will ping the
> resources that belong to the iterator into memory untill iterator.close() is
> invoked, but it didn't invoked right now. This will lead to memory leak
> finally.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)