Skip to content

Commit

Permalink
Determine pinned timestamp just before we need it
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Bafna <[email protected]>
  • Loading branch information
gbbafna committed Oct 10, 2024
1 parent 58adc18 commit 7f9d8a6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -466,7 +467,7 @@ public TimeValue timeout() {
* @param listener snapshot creation listener
*/
public void createSnapshotV2(final CreateSnapshotRequest request, final ActionListener<SnapshotInfo> listener) {
long pinnedTimestamp = System.currentTimeMillis();
AtomicLong pinnedTimestamp = new AtomicLong();
final String repositoryName = request.repository();
final String snapshotName = indexNameExpressionResolver.resolveDateMathExpression(request.snapshot());

Expand Down Expand Up @@ -578,19 +579,20 @@ public void clusterStateProcessed(String source, ClusterState oldState, final Cl
request.indicesOptions(),
request.indices()
);
pinnedTimestamp.set(System.currentTimeMillis());
final SnapshotInfo snapshotInfo = new SnapshotInfo(
snapshotId,
shardGenerations.indices().stream().map(IndexId::getName).collect(Collectors.toList()),
newEntry.dataStreams(),
pinnedTimestamp,
pinnedTimestamp.get(),
null,
System.currentTimeMillis(),
shardGenerations.totalShards(),
Collections.emptyList(),
request.includeGlobalState(),
newEntry.userMetadata(),
true,
pinnedTimestamp
pinnedTimestamp.get()
);
final Version version = minCompatibleVersion(newState.nodes().getMinNodeVersion(), repositoryData, null);
final StepListener<RepositoryData> pinnedTimestampListener = new StepListener<>();
Expand Down Expand Up @@ -645,7 +647,7 @@ public void onFailure(Exception e) {
stateWithoutSnapshotV2(newState);
listener.onFailure(e);
});
updateSnapshotPinnedTimestamp(repositoryData, snapshot, pinnedTimestamp, pinnedTimestampListener);
updateSnapshotPinnedTimestamp(repositoryData, snapshot, pinnedTimestamp.get(), pinnedTimestampListener);
}

@Override
Expand Down

0 comments on commit 7f9d8a6

Please sign in to comment.