Skip to content

Commit

Permalink
[FLINK-26757][state] Change the default value of state.backend.rocksd…
Browse files Browse the repository at this point in the history
…b.restore-overlap-fraction-threshold to 0
  • Loading branch information
fredia authored and Myasuka committed Apr 12, 2022
1 parent 87dd6fb commit 4034d3c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
</tr>
<tr>
<td><h5>state.backend.rocksdb.restore-overlap-fraction-threshold</h5></td>
<td style="word-wrap: break-word;">0.75</td>
<td style="word-wrap: break-word;">0.0</td>
<td>Double</td>
<td>The threshold of the overlap fraction between the handle's key-group range and target key-group range. When restore base DB, only the handle which overlap fraction greater than or equal to *threshold* has a chance to be an initial handle.</td>
<td>The threshold of overlap fraction between the handle's key-group range and target key-group range. When restore base DB, only the handle which overlap fraction greater than or equal to threshold has a chance to be an initial handle. The default value is 0.0, there is always a handle will be selected for initialization. </td>
</tr>
<tr>
<td><h5>state.backend.rocksdb.thread.num</h5></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend(
.setNativeMetricOptions(
resourceContainer.getMemoryWatcherOptions(defaultMetricOptions))
.setWriteBatchSize(getWriteBatchSize())
.setOverlapFractionThreshold(overlapFractionThreshold);
.setOverlapFractionThreshold(getOverlapFractionThreshold());
return builder.build();
}

Expand Down Expand Up @@ -833,6 +833,12 @@ public void setWriteBatchSize(long writeBatchSize) {
this.writeBatchSize = writeBatchSize;
}

double getOverlapFractionThreshold() {
return overlapFractionThreshold == UNDEFINED_OVERLAP_FRACTION_THRESHOLD
? RESTORE_OVERLAP_FRACTION_THRESHOLD.defaultValue()
: overlapFractionThreshold;
}

// ------------------------------------------------------------------------
// utilities
// ------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,12 @@ public class RocksDBConfigurableOptions implements Serializable {
public static final ConfigOption<Double> RESTORE_OVERLAP_FRACTION_THRESHOLD =
key("state.backend.rocksdb.restore-overlap-fraction-threshold")
.doubleType()
.defaultValue(0.75)
.defaultValue(0.0)
.withDescription(
"The threshold of the overlap fraction between the handle's key-group range and target key-group range. "
+ "When restore base DB, only the handle which overlap fraction greater than or equal to *threshold* "
+ "has a chance to be an initial handle.");
"The threshold of overlap fraction between the handle's key-group range and target key-group range. "
+ "When restore base DB, only the handle which overlap fraction greater than or equal to threshold "
+ "has a chance to be an initial handle. "
+ "The default value is 0.0, there is always a handle will be selected for initialization. ");

static final ConfigOption<?>[] CANDIDATE_CONFIGS =
new ConfigOption<?>[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ public void testChooseTheBestStateHandleForInitial() {
when(keyedStateHandle3.getKeyGroupRange()).thenReturn(new KeyGroupRange(8, 12));
keyedStateHandles.add(keyedStateHandle3);

Assert.assertNull(
RocksDBIncrementalCheckpointUtils.chooseTheBestStateHandleForInitial(
keyedStateHandles,
new KeyGroupRange(3, 5),
RESTORE_OVERLAP_FRACTION_THRESHOLD.defaultValue()));

// this should choose keyedStateHandle2, because keyedStateHandle2's key-group range
// satisfies the overlap fraction demand.
Assert.assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,24 @@ public void testConfigureIllegalMemoryControlParameters() {
}
}

@Test
public void testDefaultRestoreOverlapThreshold() {
EmbeddedRocksDBStateBackend rocksDBStateBackend = new EmbeddedRocksDBStateBackend(true);
assertTrue(
RocksDBConfigurableOptions.RESTORE_OVERLAP_FRACTION_THRESHOLD.defaultValue()
== rocksDBStateBackend.getOverlapFractionThreshold());
}

@Test
public void testConfigureRestoreOverlapThreshold() {
EmbeddedRocksDBStateBackend rocksDBStateBackend = new EmbeddedRocksDBStateBackend(true);
Configuration configuration = new Configuration();
configuration.setDouble(RocksDBConfigurableOptions.RESTORE_OVERLAP_FRACTION_THRESHOLD, 0.3);
rocksDBStateBackend =
rocksDBStateBackend.configure(configuration, getClass().getClassLoader());
assertTrue(0.3 == rocksDBStateBackend.getOverlapFractionThreshold());
}

private void verifySetParameter(Runnable setter) {
try {
setter.run();
Expand Down

0 comments on commit 4034d3c

Please sign in to comment.