You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ljz2051 (via GitHub)" <gi...@apache.org> on 2024/02/22 09:39:26 UTC
[PR] [FLINK-34050][state] Clean up useless files in deleted ranges during rescaling for RocksdbStateBackend [flink]
ljz2051 opened a new pull request, #24367:
URL: https://github.com/apache/flink/pull/24367
## What is the purpose of the change
This pull request cleans up useless sst files within rocksdb during rescaling, which reclaims local disk space, reducing the space amplification problem caused by deleteRange.
## Brief change log
- Invoke Rocksdb.deleteFilesInRanges api to delele useless files during rescaling
## Verifying this change
This change is already covered by existing tests, such as RocksDBIncrementalCheckpointUtilsTest and RocksIncrementalCheckpointRescalingTest.
## 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: yes
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
--
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-34050][state] Clean up useless files in deleted ranges during rescaling for RocksdbStateBackend [flink]
Posted by "ljz2051 (via GitHub)" <gi...@apache.org>.
ljz2051 commented on PR #24367:
URL: https://github.com/apache/flink/pull/24367#issuecomment-1965740854
@flinkbot run azure
--
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-34050][state] Clean up useless files in deleted ranges during rescaling for RocksdbStateBackend [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #24367:
URL: https://github.com/apache/flink/pull/24367#issuecomment-1959065683
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "e5e4c71c5902c3ce3e1dc43b17c4336483356904",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "e5e4c71c5902c3ce3e1dc43b17c4336483356904",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* e5e4c71c5902c3ce3e1dc43b17c4336483356904 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-34050][state] Clean up useless files in deleted ranges during rescaling for RocksdbStateBackend [flink]
Posted by "StefanRRichter (via GitHub)" <gi...@apache.org>.
StefanRRichter merged PR #24367:
URL: https://github.com/apache/flink/pull/24367
--
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-34050][state] Clean up useless files in deleted ranges during rescaling for RocksdbStateBackend [flink]
Posted by "ljz2051 (via GitHub)" <gi...@apache.org>.
ljz2051 commented on code in PR #24367:
URL: https://github.com/apache/flink/pull/24367#discussion_r1502571621
##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBIncrementalCheckpointUtils.java:
##########
@@ -153,13 +154,14 @@ private static void deleteRange(
byte[] beginKeyBytes,
byte[] endKeyBytes)
throws RocksDBException {
-
+ List<byte[]> deletedRange = Arrays.asList(beginKeyBytes, endKeyBytes);
for (ColumnFamilyHandle columnFamilyHandle : columnFamilyHandles) {
// Using RocksDB's deleteRange will take advantage of delete
// tombstones, which mark the range as deleted.
//
// https://github.com/ververica/frocksdb/blob/FRocksDB-6.20.3/include/rocksdb/db.h#L363-L377
db.deleteRange(columnFamilyHandle, beginKeyBytes, endKeyBytes);
+ db.deleteFilesInRanges(columnFamilyHandle, deletedRange, false);
Review Comment:
@StefanRRichter Thanks for your advice.
I have made changes according to your comments. Could you take one more 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-34050][state] Clean up useless files in deleted ranges during rescaling for RocksdbStateBackend [flink]
Posted by "StefanRRichter (via GitHub)" <gi...@apache.org>.
StefanRRichter commented on code in PR #24367:
URL: https://github.com/apache/flink/pull/24367#discussion_r1498971141
##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBIncrementalCheckpointUtils.java:
##########
@@ -153,13 +154,14 @@ private static void deleteRange(
byte[] beginKeyBytes,
byte[] endKeyBytes)
throws RocksDBException {
-
+ List<byte[]> deletedRange = Arrays.asList(beginKeyBytes, endKeyBytes);
for (ColumnFamilyHandle columnFamilyHandle : columnFamilyHandles) {
// Using RocksDB's deleteRange will take advantage of delete
// tombstones, which mark the range as deleted.
//
// https://github.com/ververica/frocksdb/blob/FRocksDB-6.20.3/include/rocksdb/db.h#L363-L377
db.deleteRange(columnFamilyHandle, beginKeyBytes, endKeyBytes);
+ db.deleteFilesInRanges(columnFamilyHandle, deletedRange, false);
Review Comment:
If we move the `deleteFilesInRanges` call to `clipDBWithKeyGroupRange` we can do one call instead of two, which at least according to the RocksDB java doc could be faster than calling twice. I'd also suggest to introduce parameter protection for the change and call deleteRange after deleteRangeInFiles. e.g.
```
public static void clipDBWithKeyGroupRange(
@Nonnull RocksDB db,
@Nonnull List<ColumnFamilyHandle> columnFamilyHandles,
@Nonnull KeyGroupRange targetKeyGroupRange,
@Nonnull KeyGroupRange currentKeyGroupRange,
@Nonnegative int keyGroupPrefixBytes,
boolean useDeleteFilesInRange)
throws RocksDBException {
List<byte[]> deleteFilesRanges = new ArrayList<>(4);
List<ThrowingRunnable<RocksDBException>> deleteRangeActions = new ArrayList<>(2);
if (currentKeyGroupRange.getStartKeyGroup() < targetKeyGroupRange.getStartKeyGroup()) {
byte[] beginKeyGroupBytes = new byte[keyGroupPrefixBytes];
byte[] endKeyGroupBytes = new byte[keyGroupPrefixBytes];
CompositeKeySerializationUtils.serializeKeyGroup(
currentKeyGroupRange.getStartKeyGroup(), beginKeyGroupBytes);
CompositeKeySerializationUtils.serializeKeyGroup(
targetKeyGroupRange.getStartKeyGroup(), endKeyGroupBytes);
deleteFilesRanges.add(beginKeyGroupBytes);
deleteFilesRanges.add(endKeyGroupBytes);
deleteRangeActions.add(
() ->
deleteRange(
db, columnFamilyHandles, beginKeyGroupBytes, endKeyGroupBytes));
}
if (currentKeyGroupRange.getEndKeyGroup() > targetKeyGroupRange.getEndKeyGroup()) {
byte[] beginKeyGroupBytes = new byte[keyGroupPrefixBytes];
byte[] endKeyGroupBytes = new byte[keyGroupPrefixBytes];
CompositeKeySerializationUtils.serializeKeyGroup(
targetKeyGroupRange.getEndKeyGroup() + 1, beginKeyGroupBytes);
CompositeKeySerializationUtils.serializeKeyGroup(
currentKeyGroupRange.getEndKeyGroup() + 1, endKeyGroupBytes);
deleteFilesRanges.add(beginKeyGroupBytes);
deleteFilesRanges.add(endKeyGroupBytes);
deleteRangeActions.add(
() ->
deleteRange(
db, columnFamilyHandles, beginKeyGroupBytes, endKeyGroupBytes));
}
// First delete the files.
if (useDeleteFilesInRange) {
deleteFilesInRanges(db, columnFamilyHandles, deleteFilesRanges);
}
// Then put range limiting tombstones in place.
for (ThrowingRunnable<RocksDBException> deleteRangeAction : deleteRangeActions) {
deleteRangeAction.run();
}
}
--
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