Skip to content

Commit 5e7ab2a

Browse files
authored
Merge branch 'main' into issue_14377
Signed-off-by: kkewwei <kkewwei@163.com>
2 parents ba4b35f + f8e8865 commit 5e7ab2a

37 files changed

+1446
-471
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3333
### Removed
3434

3535
### Fixed
36+
- Fix bug in SBP cancellation logic ([#13259](https://github.com/opensearch-project/OpenSearch/pull/13474))
3637
- Fix handling of Short and Byte data types in ScriptProcessor ingest pipeline ([#14379](https://github.com/opensearch-project/OpenSearch/issues/14379))
3738
- Switch to iterative version of WKT format parser ([#14086](https://github.com/opensearch-project/OpenSearch/pull/14086))
3839
- Fix the computed max shards of cluster to avoid int overflow ([#14155](https://github.com/opensearch-project/OpenSearch/pull/14155))
3940
- Fixed rest-high-level client searchTemplate & mtermVectors endpoints to have a leading slash ([#14465](https://github.com/opensearch-project/OpenSearch/pull/14465))
41+
- Write shard level metadata blob when snapshotting searchable snapshot indexes ([#13190](https://github.com/opensearch-project/OpenSearch/pull/13190))
42+
- Fix aggs result of NestedAggregator with sub NestedAggregator ([#13324](https://github.com/opensearch-project/OpenSearch/pull/13324))
43+
- Add ListPitInfo::getKeepAlive() getter ([#14495](https://github.com/opensearch-project/OpenSearch/pull/14495))
4044
- Fix FuzzyQuery in keyword field will use IndexOrDocValuesQuery when both of index and doc_value are true ([#14378](https://github.com/opensearch-project/OpenSearch/pull/14378))
4145

4246
### Security

TESTING.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,23 @@ This will instruct all JVMs (including any that run cli tools such as creating t
9191

9292
## Test case filtering
9393

94-
- `tests.class` is a class-filtering shell-like glob pattern
95-
- `tests.method` is a method-filtering glob pattern.
94+
To be able to run a single test you need to specify the module where you're running the tests from.
95+
96+
Example: `./gradlew server:test --tests "*.ReplicaShardBatchAllocatorTests.testNoAsyncFetchData"`
9697

9798
Run a single test case (variants)
9899

99-
./gradlew test -Dtests.class=org.opensearch.package.ClassName
100-
./gradlew test "-Dtests.class=*.ClassName"
100+
./gradlew module:test --tests org.opensearch.package.ClassName
101+
./gradlew module:test --tests org.opensearch.package.ClassName.testName
102+
./gradlew module:test --tests "*.ClassName"
101103

102104
Run all tests in a package and its sub-packages
103105

104-
./gradlew test "-Dtests.class=org.opensearch.package.*"
106+
./gradlew module:test --tests "org.opensearch.package.*"
105107

106108
Run any test methods that contain *esi* (e.g.: .r*esi*ze.)
107109

108-
./gradlew test "-Dtests.method=*esi*"
110+
./gradlew module:test --tests "*esi*"
109111

110112
Run all tests that are waiting for a bugfix (disabled by default)
111113

server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ public void testPitCreatedOnReplica() throws Exception {
14051405
.setPointInTime(new PointInTimeBuilder(pitResponse.getId()).setKeepAlive(TimeValue.timeValueDays(1)))
14061406
.setRequestCache(false)
14071407
.get();
1408-
PitTestsUtil.assertUsingGetAllPits(client(replica), pitResponse.getId(), pitResponse.getCreationTime());
1408+
PitTestsUtil.assertUsingGetAllPits(client(replica), pitResponse.getId(), pitResponse.getCreationTime(), TimeValue.timeValueDays(1));
14091409
assertSegments(false, INDEX_NAME, 1, client(replica), pitResponse.getId());
14101410

14111411
List<String> currentFiles = List.of(replicaShard.store().directory().listAll());

server/src/internalClusterTest/java/org/opensearch/search/pit/PitMultiNodeIT.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void testPit() throws Exception {
104104
assertEquals(2, searchResponse.getSuccessfulShards());
105105
assertEquals(2, searchResponse.getTotalShards());
106106
validatePitStats("index", 2, 2);
107-
PitTestsUtil.assertUsingGetAllPits(client(), pitResponse.getId(), pitResponse.getCreationTime());
107+
PitTestsUtil.assertUsingGetAllPits(client(), pitResponse.getId(), pitResponse.getCreationTime(), TimeValue.timeValueDays(1));
108108
assertSegments(false, client(), pitResponse.getId());
109109
}
110110

@@ -131,7 +131,12 @@ public void testCreatePitWhileNodeDropWithAllowPartialCreationTrue() throws Exce
131131
public Settings onNodeStopped(String nodeName) throws Exception {
132132
ActionFuture<CreatePitResponse> execute = client().execute(CreatePitAction.INSTANCE, request);
133133
CreatePitResponse pitResponse = execute.get();
134-
PitTestsUtil.assertUsingGetAllPits(client(), pitResponse.getId(), pitResponse.getCreationTime());
134+
PitTestsUtil.assertUsingGetAllPits(
135+
client(),
136+
pitResponse.getId(),
137+
pitResponse.getCreationTime(),
138+
TimeValue.timeValueDays(1)
139+
);
135140
assertSegments(false, "index", 1, client(), pitResponse.getId());
136141
assertEquals(1, pitResponse.getSuccessfulShards());
137142
assertEquals(2, pitResponse.getTotalShards());
@@ -164,7 +169,12 @@ public Settings onNodeStopped(String nodeName) throws Exception {
164169
assertEquals(0, searchResponse.getSkippedShards());
165170
assertEquals(2, searchResponse.getTotalShards());
166171
validatePitStats("index", 1, 1);
167-
PitTestsUtil.assertUsingGetAllPits(client(), pitResponse.getId(), pitResponse.getCreationTime());
172+
PitTestsUtil.assertUsingGetAllPits(
173+
client(),
174+
pitResponse.getId(),
175+
pitResponse.getCreationTime(),
176+
TimeValue.timeValueDays(1)
177+
);
168178
return super.onNodeStopped(nodeName);
169179
}
170180
});

server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java

+37-18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.opensearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
1818
import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
1919
import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
20+
import org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
2021
import org.opensearch.action.admin.indices.settings.get.GetSettingsRequest;
2122
import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse;
2223
import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequestBuilder;
@@ -53,11 +54,13 @@
5354
import java.nio.file.Files;
5455
import java.nio.file.Path;
5556
import java.util.Arrays;
57+
import java.util.HashMap;
5658
import java.util.List;
5759
import java.util.Map;
5860
import java.util.Set;
5961
import java.util.concurrent.TimeUnit;
6062
import java.util.stream.Collectors;
63+
import java.util.stream.IntStream;
6164
import java.util.stream.Stream;
6265
import java.util.stream.StreamSupport;
6366

@@ -132,21 +135,24 @@ public void testCreateSearchableSnapshot() throws Exception {
132135

133136
public void testSnapshottingSearchableSnapshots() throws Exception {
134137
final String repoName = "test-repo";
138+
final String initSnapName = "initial-snapshot";
135139
final String indexName = "test-idx";
140+
final String repeatSnapNamePrefix = "test-repeated-snap-";
141+
final String repeatIndexNamePrefix = indexName + "-copy-";
136142
final Client client = client();
137143

138144
// create an index, add data, snapshot it, then delete it
139145
internalCluster().ensureAtLeastNumDataNodes(1);
140146
createIndexWithDocsAndEnsureGreen(0, 100, indexName);
141147
createRepositoryWithSettings(null, repoName);
142-
takeSnapshot(client, "initial-snapshot", repoName, indexName);
148+
takeSnapshot(client, initSnapName, repoName, indexName);
143149
deleteIndicesAndEnsureGreen(client, indexName);
144150

145151
// restore the index as a searchable snapshot
146152
internalCluster().ensureAtLeastNumSearchNodes(1);
147153
client.admin()
148154
.cluster()
149-
.prepareRestoreSnapshot(repoName, "initial-snapshot")
155+
.prepareRestoreSnapshot(repoName, initSnapName)
150156
.setRenamePattern("(.+)")
151157
.setRenameReplacement("$1-copy-0")
152158
.setStorageType(RestoreSnapshotRequest.StorageType.REMOTE_SNAPSHOT)
@@ -159,7 +165,7 @@ public void testSnapshottingSearchableSnapshots() throws Exception {
159165

160166
// Test that the searchable snapshot index can continue to be snapshotted and restored
161167
for (int i = 0; i < 4; i++) {
162-
final String repeatedSnapshotName = "test-repeated-snap-" + i;
168+
final String repeatedSnapshotName = repeatSnapNamePrefix + i;
163169
takeSnapshot(client, repeatedSnapshotName, repoName);
164170
deleteIndicesAndEnsureGreen(client, "_all");
165171
client.admin()
@@ -181,21 +187,34 @@ public void testSnapshottingSearchableSnapshots() throws Exception {
181187
final Map<String, List<String>> snapshotInfoMap = response.getSnapshots()
182188
.stream()
183189
.collect(Collectors.toMap(s -> s.snapshotId().getName(), SnapshotInfo::indices));
184-
assertEquals(
185-
Map.of(
186-
"initial-snapshot",
187-
List.of("test-idx"),
188-
"test-repeated-snap-0",
189-
List.of("test-idx-copy-0"),
190-
"test-repeated-snap-1",
191-
List.of("test-idx-copy-1"),
192-
"test-repeated-snap-2",
193-
List.of("test-idx-copy-2"),
194-
"test-repeated-snap-3",
195-
List.of("test-idx-copy-3")
196-
),
197-
snapshotInfoMap
198-
);
190+
final Map<String, List<String>> expect = new HashMap<>();
191+
expect.put(initSnapName, List.of(indexName));
192+
IntStream.range(0, 4).forEach(i -> expect.put(repeatSnapNamePrefix + i, List.of(repeatIndexNamePrefix + i)));
193+
assertEquals(expect, snapshotInfoMap);
194+
195+
String[] snapNames = new String[5];
196+
IntStream.range(0, 4).forEach(i -> snapNames[i] = repeatSnapNamePrefix + i);
197+
snapNames[4] = initSnapName;
198+
SnapshotsStatusResponse snapshotsStatusResponse = client.admin()
199+
.cluster()
200+
.prepareSnapshotStatus(repoName)
201+
.addSnapshots(snapNames)
202+
.execute()
203+
.actionGet();
204+
snapshotsStatusResponse.getSnapshots().forEach(s -> {
205+
String snapName = s.getSnapshot().getSnapshotId().getName();
206+
assertEquals(1, s.getIndices().size());
207+
assertEquals(1, s.getShards().size());
208+
if (snapName.equals("initial-snapshot")) {
209+
assertNotNull(s.getIndices().get("test-idx"));
210+
assertTrue(s.getShards().get(0).getStats().getTotalFileCount() > 0);
211+
} else {
212+
assertTrue(snapName.startsWith(repeatSnapNamePrefix));
213+
assertEquals(1, s.getIndices().size());
214+
assertNotNull(s.getIndices().get(repeatIndexNamePrefix + snapName.substring(repeatSnapNamePrefix.length())));
215+
assertEquals(0L, s.getShards().get(0).getStats().getTotalFileCount());
216+
}
217+
});
199218
}
200219

201220
/**

server/src/main/java/org/opensearch/action/search/ListPitInfo.java

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public long getCreationTime() {
5353
return creationTime;
5454
}
5555

56+
public long getKeepAlive() {
57+
return keepAlive;
58+
}
59+
5660
@Override
5761
public void writeTo(StreamOutput out) throws IOException {
5862
out.writeString(pitId);

server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,8 @@ private ClusterState readClusterStateInParallel(
11601160
for (Map.Entry<String, UploadedMetadataAttribute> entry : clusterStateCustomToRead.entrySet()) {
11611161
asyncMetadataReadActions.add(
11621162
remoteClusterStateAttributesManager.getAsyncMetadataReadAction(
1163-
CLUSTER_STATE_CUSTOM,
1163+
// pass component name as cluster-state-custom--<custom_name>, so that we can interpret it later
1164+
String.join(CUSTOM_DELIMITER, CLUSTER_STATE_CUSTOM, entry.getKey()),
11641165
new RemoteClusterStateCustoms(
11651166
entry.getValue().getUploadedFilename(),
11661167
entry.getValue().getAttributeName(),

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -2801,9 +2801,12 @@ public void snapshotShard(
28012801
long indexIncrementalSize = 0;
28022802
long indexTotalFileSize = 0;
28032803
final BlockingQueue<BlobStoreIndexShardSnapshot.FileInfo> filesToSnapshot = new LinkedBlockingQueue<>();
2804-
// If we did not find a set of files that is equal to the current commit we determine the files to upload by comparing files
2805-
// in the commit with files already in the repository
2806-
if (filesFromSegmentInfos == null) {
2804+
if (store.indexSettings().isRemoteSnapshot()) {
2805+
// If the source of the data is another remote snapshot (i.e. searchable snapshot) then no need to snapshot the shard
2806+
indexCommitPointFiles = List.of();
2807+
} else if (filesFromSegmentInfos == null) {
2808+
// If we did not find a set of files that is equal to the current commit we determine the files to upload by comparing files
2809+
// in the commit with files already in the repository
28072810
indexCommitPointFiles = new ArrayList<>();
28082811
final Collection<String> fileNames;
28092812
final Store.MetadataSnapshot metadataFromStore;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.search;
10+
11+
/**
12+
* Enum to hold the resource type
13+
*/
14+
public enum ResourceType {
15+
CPU("cpu"),
16+
JVM("jvm");
17+
18+
private final String name;
19+
20+
ResourceType(String name) {
21+
this.name = name;
22+
}
23+
24+
/**
25+
* The string match here is case-sensitive
26+
* @param s name matching the resource type name
27+
* @return a {@link ResourceType}
28+
*/
29+
public static ResourceType fromName(String s) {
30+
for (ResourceType resourceType : values()) {
31+
if (resourceType.getName().equals(s)) {
32+
return resourceType;
33+
}
34+
}
35+
throw new IllegalArgumentException("Unknown resource type: [" + s + "]");
36+
}
37+
38+
private String getName() {
39+
return name;
40+
}
41+
}

0 commit comments

Comments
 (0)