Skip to content

Commit f5a44d4

Browse files
be smarter with shard generations to always allow for concurrent stuff
1 parent ca50bf4 commit f5a44d4

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,13 @@ public void testConcurrentSnapshotWorksWithOldVersionRepo() throws Exception {
11521152
final String indexFast = "index-fast";
11531153
createIndexWithContent(indexFast, dataNode2, dataNode);
11541154

1155-
assertSuccessful(client().admin().cluster().prepareCreateSnapshot(repoName, "fast-snapshot")
1156-
.setIndices(indexFast).setWaitForCompletion(true).execute());
1155+
final ActionFuture<CreateSnapshotResponse> createFastSnapshot =
1156+
client().admin().cluster().prepareCreateSnapshot(repoName, "fast-snapshot").setWaitForCompletion(true).execute();
11571157

11581158
assertThat(createSlowFuture.isDone(), is(false));
11591159
unblockNode(repoName, dataNode);
11601160

1161+
assertSuccessful(createFastSnapshot);
11611162
assertSuccessful(createSlowFuture);
11621163

11631164
final RepositoryData repositoryData = getRepositoryData(repoName);

server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ public void snapshotShard(Store store, MapperService mapperService, SnapshotId s
17591759
final ShardId shardId = store.shardId();
17601760
final long startTime = threadPool.absoluteTimeInMillis();
17611761
try {
1762-
final String generation = ShardGenerations.fixShardGeneration(snapshotStatus.generation());
1762+
final String generation = snapshotStatus.generation();
17631763
logger.debug("[{}] [{}] snapshot to [{}] [{}] ...", shardId, snapshotId, metadata.name(), generation);
17641764
final BlobContainer shardContainer = shardContainer(indexId, shardId);
17651765
final Set<String> blobs;
@@ -2238,8 +2238,6 @@ public BlobStoreIndexShardSnapshot loadShardSnapshot(BlobContainer shardContaine
22382238
private Tuple<BlobStoreIndexShardSnapshots, String> buildBlobStoreIndexShardSnapshots(Set<String> blobs,
22392239
BlobContainer shardContainer,
22402240
@Nullable String generation) throws IOException {
2241-
assert ShardGenerations.fixShardGeneration(generation) == generation
2242-
: "Generation must not be numeric but received [" + generation + "]";
22432241
if (generation != null) {
22442242
if (generation.equals(ShardGenerations.NEW_SHARD_GEN)) {
22452243
return new Tuple<>(BlobStoreIndexShardSnapshots.EMPTY, ShardGenerations.NEW_SHARD_GEN);

server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.elasticsearch.repositories.IndexId;
5454
import org.elasticsearch.repositories.RepositoriesService;
5555
import org.elasticsearch.repositories.Repository;
56+
import org.elasticsearch.repositories.ShardGenerations;
5657
import org.elasticsearch.threadpool.ThreadPool;
5758
import org.elasticsearch.transport.TransportException;
5859
import org.elasticsearch.transport.TransportRequestDeduplicator;
@@ -250,8 +251,10 @@ private void startNewShards(SnapshotsInProgress.Entry entry, Map<ShardId, IndexS
250251
final IndexShardSnapshotStatus snapshotStatus = shardEntry.getValue();
251252
final IndexId indexId = indicesMap.get(shardId.getIndexName());
252253
assert indexId != null;
253-
assert SnapshotsService.useShardGenerations(entry.version()) || snapshotStatus.generation() == null :
254-
"Found non-null shard generation [" + snapshotStatus.generation() + "] for snapshot with old-format compatibility";
254+
assert SnapshotsService.useShardGenerations(entry.version()) ||
255+
ShardGenerations.fixShardGeneration(snapshotStatus.generation()) == null :
256+
"Found non-null, non-numeric shard generation [" + snapshotStatus.generation() +
257+
"] for snapshot with old-format compatibility";
255258
snapshot(shardId, snapshot, indexId, entry.userMetadata(), snapshotStatus, entry.version(),
256259
new ActionListener<>() {
257260
@Override

0 commit comments

Comments
 (0)