Skip to content

Commit a076662

Browse files
committed
Clear heartbeats after rebuild (whting the same transaction)
1 parent d240fed commit a076662

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/logging/LogMessageKeys.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public enum LogMessageKeys {
5858
TRANSACTION_ID,
5959
TRANSACTION_NAME,
6060
AGE_SECONDS,
61+
AGE_MILLISECONDS,
6162
CONSTITUENT,
6263
TOTAL_MICROS,
6364
// record splitting/unsplitting
@@ -162,6 +163,7 @@ public enum LogMessageKeys {
162163
RECORDS_PER_SECOND,
163164
DOCUMENT,
164165
SESSION_ID,
166+
EXISTING_SESSION_ID,
165167
INDEXER_SESSION_ID,
166168
INDEXER_ID,
167169
INDEX_STATE_PRECONDITION,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,11 @@ public CompletableFuture<Void> rebuildIndexAsync(@Nonnull FDBRecordStore store)
10271027
return rangeSet.insertRangeAsync(null, null);
10281028
}))
10291029
.thenCompose(vignore -> setIndexingTypeOrThrow(store, false))
1030-
.thenCompose(vignore -> rebuildIndexInternalAsync(store));
1030+
.thenCompose(vignore -> rebuildIndexInternalAsync(store))
1031+
.thenCompose(vignore -> forEachTargetIndex(index -> {
1032+
clearHeartbeatSingleTarget(store, index);
1033+
return null;
1034+
}));
10311035
}
10321036

10331037
abstract CompletableFuture<Void> rebuildIndexInternalAsync(FDBRecordStore store);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ private void validateNonCompetingHeartbeat(KeyValue kv) {
9696
final IndexBuildProto.IndexingHeartbeat otherHeartbeat = IndexBuildProto.IndexingHeartbeat.parseFrom(kv.getValue());
9797
final long age = now - otherHeartbeat.getHeartbeatTimeMilliseconds();
9898
if (age > 0 && age < leaseLength) {
99-
throw new SynchronizedSessionLockedException("Failed to initialize the session because of an existing session in progress");
99+
throw new SynchronizedSessionLockedException("Failed to initialize the session because of an existing session in progress")
100+
.addLogInfo(LogMessageKeys.SESSION_ID, sessionId)
101+
.addLogInfo(LogMessageKeys.EXISTING_SESSION_ID, otherSessionId)
102+
.addLogInfo(LogMessageKeys.AGE_MILLISECONDS, age)
103+
.addLogInfo(LogMessageKeys.TIME_LIMIT_MILLIS, leaseLength);
100104
// TODO: log details
101105
}
102106
} catch (InvalidProtocolBufferException e) {

0 commit comments

Comments
 (0)