You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "leekeiabstraction (via GitHub)" <gi...@apache.org> on 2026/05/28 09:12:29 UTC
[PR] [FLINK-39753][state/rocksdb] Close ColumnFamilyOptions from getDescriptor() in Compactor (1.20 backport) [flink]
leekeiabstraction opened a new pull request, #28271:
URL: https://github.com/apache/flink/pull/28271
Backport of #28251 to `release-1.20`.
## What is the purpose of the change
Fixes a native memory leak in the RocksDB SST merge `Compactor`. `ColumnFamilyHandle.getDescriptor()` copies the column family's options across JNI and returns a fresh native `ColumnFamilyOptions` on every call. `Compactor.compact()` read `numLevels()` from it but never closed it, so the native object leaked on every compaction. Because the leaked options retain a reference to the shared block cache (via `BlockBasedTableFactory` -> `BlockBasedTableOptions` -> `LRUCache`), the cache's `shared_ptr` is never released, preventing the block cache from being freed even after all tasks stop. This causes task manager RSS to grow and eventually OOM.
## Brief change log
- Wrap `cfName.getDescriptor().getOptions()` in a try-with-resources block in `Compactor.compact()` so the native `ColumnFamilyOptions` is closed after `numLevels()` is read.
## Verifying this change
The leak and the fix were verified with jemalloc profiling (`jeprof`), running Flink in session mode and repeatedly starting/stopping jobs to trigger the compactor while tracking the `rocksdb::BlockFetcher::ReadBlockContents` call stack that dominates block-cache allocations. The configured block cache capacity was 833MB.
- **Before the fix:** after jobs were stopped and resubmitted, `ReadBlockContents` grew to ~1.54GB, far exceeding the 833MB cache capacity; the jemalloc heap profile reported a total of 2,280,777,636 bytes.
- **After the fix:** the task manager with the highest RSS held ~800MB in `ReadBlockContents`, consistent with the 833MB capacity; the jemalloc heap profile reported a total of 1,416,132,765 bytes.
This is a ~37% reduction in native memory usage and eliminates the cache-capacity overage, confirming the `LRUCache` leak caused by the unclosed `ColumnFamilyOptions` is resolved. The behavior (output level computation) is unchanged and is covered by existing tests; only the previously-leaked native handle is now closed.
## 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: 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
--
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-39753][state/rocksdb] Close ColumnFamilyOptions from getDescriptor() in Compactor (1.20 backport) [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #28271:
URL: https://github.com/apache/flink/pull/28271
--
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-39753][state/rocksdb] Close ColumnFamilyOptions from getDescriptor() in Compactor (1.20 backport) [flink]
Posted by "leekeiabstraction (via GitHub)" <gi...@apache.org>.
leekeiabstraction commented on PR #28271:
URL: https://github.com/apache/flink/pull/28271#issuecomment-4567464656
CI failure was due to unrelated minio container startup failure
```
May 28 10:40:12 10:40:12.399 [ERROR] Errors:
May 28 10:40:12 10:40:12.399 [ERROR] MinioTestContainerTest.testBucketCreation » ContainerLaunch Container startup failed for image minio/minio:RELEASE.2022-02-07T08-17-33Z
May 28 10:40:12 10:40:12.399 [ERROR] MinioTestContainerTest.testDefaultBucketCreation » ContainerLaunch Container startup failed for image minio/minio:RELEASE.2022-02-07T08-17-33Z
May 28 10:40:12 10:40:12.399 [ERROR] MinioTestContainerTest.testGetDefaultBucketName » ContainerLaunch Container startup failed for image minio/minio:RELEASE.2022-02-07T08-17-33Z
May 28 10:40:12 10:40:12.399 [ERROR] MinioTestContainerTest.testPutObject » ContainerLaunch Container startup failed for image minio/minio:RELEASE.2022-02-07T08-17-33Z
May 28 10:40:12 10:40:12.399 [ERROR] MinioTestContainerTest.testS3EndpointNeedsToBeSpecifiedBeforeInitializingFileSyste » ContainerLaunch Container startup failed for image minio/minio:RELEASE.2022-02-07T08-17-33Z
May 28 10:40:12 10:40:12.399 [ERROR] MinioTestContainerTest.testSetS3ConfigOptions » Runtime org.testcontainers.shaded.com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2022-09-25T19:30:31.944216577+08:00": not a valid representation (error: Failed to parse Date value '2022-09-25T19:30:31.944216577+08:00': Can not parse date "2022-09-25T19:30:31.944216577+0800": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))
May 28 10:40:12 at [Source: N/A; line: -1, column: -1] (through reference chain: com.github.dockerjava.api.model.Network["Created"])
May 28 10:40:12 10:40:12.399 [INFO]
May 28 10:40:12 10:40:12.399 [ERROR] Tests run: 49, Failures: 0, Errors: 6, Skipped: 0
```
--
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-39753][state/rocksdb] Close ColumnFamilyOptions from getDescriptor() in Compactor (1.20 backport) [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28271:
URL: https://github.com/apache/flink/pull/28271#issuecomment-4562574444
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "73b226d12a5e5ca852684b088ce843d0016be735",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "73b226d12a5e5ca852684b088ce843d0016be735",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 73b226d12a5e5ca852684b088ce843d0016be735 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-39753][state/rocksdb] Close ColumnFamilyOptions from getDescriptor() in Compactor (1.20 backport) [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #28271:
URL: https://github.com/apache/flink/pull/28271#issuecomment-4587546628
not related to the PR, same was failing before
I tend to think it is Azure related issue, same pipeline passed in GHA
--
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