Skip to content

Commit dbaf2f8

Browse files
authored
Make INDEX_SCRUBBED_INDEX_RANGES unique + more (#3306)
Resolve #3305 1. Make `INDEX_SCRUBBED_INDEX_RANGES` unique (bug fix) 2. Make the constructor of `ScrubbingPolicy` private (it was never meant to be public) 3. Rename new `ScrubbingPolicy.getRangeId` to `getScrubbingRangeId` 4. Rename new `ScrubbingPolicy.isRangeReset` to `isScrubbingRangeReset`
1 parent b2fb8fc commit dbaf2f8

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexScrubbing.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ List<Object> indexingLogMessageKeyValues() {
8787
return Arrays.asList(
8888
LogMessageKeys.INDEXING_METHOD, scrubberName,
8989
LogMessageKeys.ALLOW_REPAIR, scrubbingPolicy.allowRepair(),
90-
LogMessageKeys.RANGE_ID, scrubbingPolicy.getRangeId(),
91-
LogMessageKeys.RANGE_RESET, scrubbingPolicy.isRangeReset(),
90+
LogMessageKeys.RANGE_ID, scrubbingPolicy.getScrubbingRangeId(),
91+
LogMessageKeys.RANGE_RESET, scrubbingPolicy.isScrubbingRangeReset(),
9292
LogMessageKeys.SCRUB_TYPE, scrubbingType,
9393
LogMessageKeys.SCAN_LIMIT, scrubbingPolicy.getEntriesScanLimit()
9494
);
@@ -233,9 +233,9 @@ private void reportIssues(List<IndexScrubbingTools.Issue> issueList, Throwable e
233233
IndexingRangeSet getRangeset(FDBRecordStore store, Index index) {
234234
switch (scrubbingType) {
235235
case MISSING:
236-
return IndexingRangeSet.forScrubbingRecords(store, index, scrubbingPolicy.getRangeId());
236+
return IndexingRangeSet.forScrubbingRecords(store, index, scrubbingPolicy.getScrubbingRangeId());
237237
case DANGLING:
238-
return IndexingRangeSet.forScrubbingIndex(store, index, scrubbingPolicy.getRangeId());
238+
return IndexingRangeSet.forScrubbingIndex(store, index, scrubbingPolicy.getScrubbingRangeId());
239239
default:
240240
throw new RecordCoreArgumentException("Unpredicted scrubbing type ");
241241
}
@@ -252,7 +252,7 @@ protected CompletableFuture<Void> setScrubberTypeOrThrow(FDBRecordStore store) {
252252

253253
final Index index = common.getIndex(); // Note: multi targets mode is not supported (yet)
254254
final IndexingRangeSet rangeSet = getRangeset(store, index);
255-
if (scrubbingPolicy.isRangeReset()) {
255+
if (scrubbingPolicy.isScrubbingRangeReset()) {
256256
logScrubberRangeReset("forced reset");
257257
rangeSet.clear();
258258
return AsyncUtil.DONE;

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingScrubDangling.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ List<Object> indexingLogMessageKeyValues() {
8888
return Arrays.asList(
8989
LogMessageKeys.INDEXING_METHOD, "scrub dangling index entries",
9090
LogMessageKeys.ALLOW_REPAIR, scrubbingPolicy.allowRepair(),
91-
LogMessageKeys.RANGE_ID, scrubbingPolicy.getRangeId(),
92-
LogMessageKeys.RANGE_RESET, scrubbingPolicy.isRangeReset(),
91+
LogMessageKeys.RANGE_ID, scrubbingPolicy.getScrubbingRangeId(),
92+
LogMessageKeys.RANGE_RESET, scrubbingPolicy.isScrubbingRangeReset(),
9393
LogMessageKeys.SCAN_LIMIT, scrubbingPolicy.getEntriesScanLimit()
9494
);
9595
}
@@ -149,7 +149,7 @@ private CompletableFuture<Boolean> scrubIndexRangeOnly(@Nonnull FDBRecordStore s
149149
validateOrThrowEx(store.getIndexState(index).isScannable(), "scrubbed index is not readable");
150150

151151
final ScanProperties scanProperties = scanPropertiesWithLimits(true);
152-
final IndexingRangeSet rangeSet = IndexingRangeSet.forScrubbingIndex(store, index, scrubbingPolicy.getRangeId());
152+
final IndexingRangeSet rangeSet = IndexingRangeSet.forScrubbingIndex(store, index, scrubbingPolicy.getScrubbingRangeId());
153153
return rangeSet.firstMissingRangeAsync().thenCompose(range -> {
154154
if (range == null) {
155155
// Here: no more missing ranges - all done
@@ -258,8 +258,8 @@ protected CompletableFuture<Void> setScrubberTypeOrThrow(FDBRecordStore store) {
258258
"Not a scrubber type-stamp");
259259

260260
final Index index = common.getIndex(); // Note: the scrubbers do not support multi target (yet)
261-
IndexingRangeSet indexRangeSet = IndexingRangeSet.forScrubbingIndex(store, index, scrubbingPolicy.getRangeId());
262-
if (scrubbingPolicy.isRangeReset()) {
261+
IndexingRangeSet indexRangeSet = IndexingRangeSet.forScrubbingIndex(store, index, scrubbingPolicy.getScrubbingRangeId());
262+
if (scrubbingPolicy.isScrubbingRangeReset()) {
263263
indexRangeSet.clear();
264264
if (LOGGER.isInfoEnabled()) {
265265
LOGGER.info(KeyValueLogMessage.build("Reset index scrubbing range")

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingScrubMissing.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ List<Object> indexingLogMessageKeyValues() {
8787
return Arrays.asList(
8888
LogMessageKeys.INDEXING_METHOD, "scrub missing index entries",
8989
LogMessageKeys.ALLOW_REPAIR, scrubbingPolicy.allowRepair(),
90-
LogMessageKeys.RANGE_ID, scrubbingPolicy.getRangeId(),
91-
LogMessageKeys.RANGE_RESET, scrubbingPolicy.isRangeReset(),
90+
LogMessageKeys.RANGE_ID, scrubbingPolicy.getScrubbingRangeId(),
91+
LogMessageKeys.RANGE_RESET, scrubbingPolicy.isScrubbingRangeReset(),
9292
LogMessageKeys.SCAN_LIMIT, scrubbingPolicy.getEntriesScanLimit()
9393
);
9494
}
@@ -147,7 +147,7 @@ private CompletableFuture<Boolean> scrubRecordsRangeOnly(@Nonnull FDBRecordStore
147147
validateOrThrowEx(store.getIndexState(index).isScannable(), "scrubbed index is not readable");
148148

149149
final ScanProperties scanProperties = scanPropertiesWithLimits(true);
150-
final IndexingRangeSet rangeSet = IndexingRangeSet.forScrubbingRecords(store, index, scrubbingPolicy.getRangeId());
150+
final IndexingRangeSet rangeSet = IndexingRangeSet.forScrubbingRecords(store, index, scrubbingPolicy.getScrubbingRangeId());
151151
return rangeSet.firstMissingRangeAsync().thenCompose(range -> {
152152
if (range == null) {
153153
// Here: no more missing ranges - all done
@@ -284,8 +284,8 @@ protected CompletableFuture<Void> setScrubberTypeOrThrow(FDBRecordStore store) {
284284
"Not a scrubber type-stamp");
285285

286286
final Index index = common.getIndex(); // Note: the scrubbers do not support multi target (yet)
287-
IndexingRangeSet recordsRangeSet = IndexingRangeSet.forScrubbingRecords(store, index, scrubbingPolicy.getRangeId());
288-
if (scrubbingPolicy.isRangeReset()) {
287+
IndexingRangeSet recordsRangeSet = IndexingRangeSet.forScrubbingRecords(store, index, scrubbingPolicy.getScrubbingRangeId());
288+
if (scrubbingPolicy.isScrubbingRangeReset()) {
289289
if (LOGGER.isInfoEnabled()) {
290290
LOGGER.info(KeyValueLogMessage.build("Reset index scrubbing range")
291291
.addKeysAndValues(common.indexLogMessageKeyValues())

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingSubspaces.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public final class IndexingSubspaces {
3838
private static final Object INDEX_BUILD_TYPE_VERSION = 2L;
3939
private static final Object INDEX_SCRUBBED_INDEX_RANGES_ZERO = 3L;
4040
private static final Object INDEX_SCRUBBED_RECORDS_RANGES_ZERO = 4L;
41-
private static final Object INDEX_SCRUBBED_INDEX_RANGES = 4L;
4241
private static final Object INDEX_SCRUBBED_RECORDS_RANGES = 5L;
42+
private static final Object INDEX_SCRUBBED_INDEX_RANGES = 6L;
4343

4444
private IndexingSubspaces() {
4545
throw new IllegalStateException("Utility class");
@@ -50,6 +50,12 @@ private static Subspace indexBuildSubspace(@Nonnull FDBRecordStoreBase<?> store,
5050
return store.getUntypedRecordStore().indexBuildSubspace(index).subspace(Tuple.from(key));
5151
}
5252

53+
/**
54+
* Subspace that stores the lock for a synced indexing session.
55+
* @param store store
56+
* @param index index
57+
* @return subspace
58+
*/
5359
@Nonnull
5460
public static Subspace indexBuildLockSubspace(@Nonnull FDBRecordStoreBase<?> store, @Nonnull Index index) {
5561
return indexBuildSubspace(store, index, INDEX_BUILD_LOCK_KEY);

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexScrubber.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ public static class ScrubbingPolicy {
146146
private final int rangeId;
147147
private final boolean rangeReset;
148148

149-
@Deprecated(since = "4.2.2.1", forRemoval = true)
150-
public ScrubbingPolicy(int logWarningsLimit, boolean allowRepair, long entriesScanLimit,
149+
private ScrubbingPolicy(int logWarningsLimit, boolean allowRepair, long entriesScanLimit,
151150
boolean ignoreIndexTypeCheck, boolean useLegacy, int rangeId, boolean rangeReset) {
152151

153152
this.logWarningsLimit = logWarningsLimit;
@@ -179,11 +178,11 @@ public int getLogWarningsLimit() {
179178
return logWarningsLimit;
180179
}
181180

182-
public int getRangeId() {
181+
public int getScrubbingRangeId() {
183182
return rangeId;
184183
}
185184

186-
public boolean isRangeReset() {
185+
public boolean isScrubbingRangeReset() {
187186
return rangeReset;
188187
}
189188

@@ -290,11 +289,11 @@ public Builder useLegacyScrubber(boolean legacy) {
290289
}
291290

292291
/**
293-
* Choose a specific id for this scrubbing operation. If the scrubbing stops, then later it can be resumed
294-
* at a later time by constructing the same builder.
292+
* Choose a specific id for this scrubbing operation. If the scrubbing stops, then it can be resumed
293+
* by constructing the same builder.
295294
* Work done with other ids will not affect work done with this id.
296295
* 0 is the backward compatible default, which means no prefix.
297-
* @param rangeId a rangeSet prefix
296+
* @param rangeId an id for isolating this scrubbing work
298297
* @return this builder
299298
*/
300299
public Builder setScrubbingRangeId(final int rangeId) {

0 commit comments

Comments
 (0)