Skip to content

Commit bb9a42b

Browse files
authored
Merge branch 'main' into feature/shard_ref_count
2 parents de0d4bd + 876c456 commit bb9a42b

File tree

15 files changed

+254
-100
lines changed

15 files changed

+254
-100
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,6 @@ tests:
565565
- class: org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapperTests
566566
method: testExistsQueryMinimalMapping
567567
issue: https://github.com/elastic/elasticsearch/issues/129911
568-
- class: org.elasticsearch.index.mapper.DynamicMappingIT
569-
method: testDenseVectorDynamicMapping
570-
issue: https://github.com/elastic/elasticsearch/issues/129928
571568

572569
# Examples:
573570
#

server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -920,19 +920,27 @@ public void testDenseVectorDynamicMapping() throws Exception {
920920

921921
client().index(
922922
new IndexRequest("test").source("vector_int8", Randomness.get().doubles(BBQ_DIMS_DEFAULT_THRESHOLD - 1, 0.0, 5.0).toArray())
923+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
923924
).get();
924925
client().index(
925926
new IndexRequest("test").source("vector_bbq", Randomness.get().doubles(BBQ_DIMS_DEFAULT_THRESHOLD, 0.0, 5.0).toArray())
927+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
926928
).get();
927-
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
928-
.get()
929-
.mappings()
930-
.get("test")
931-
.sourceAsMap();
932-
assertTrue(new WriteField("properties.vector_int8", () -> mappings).exists());
933-
assertTrue(new WriteField("properties.vector_int8.index_options.type", () -> mappings).get(null).toString().equals("int8_hnsw"));
934-
assertTrue(new WriteField("properties.vector_bbq", () -> mappings).exists());
935-
assertTrue(new WriteField("properties.vector_bbq.index_options.type", () -> mappings).get(null).toString().equals("bbq_hnsw"));
929+
930+
assertBusy(() -> {
931+
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
932+
.get()
933+
.mappings()
934+
.get("test")
935+
.sourceAsMap();
936+
937+
assertTrue(new WriteField("properties.vector_int8", () -> mappings).exists());
938+
assertTrue(
939+
new WriteField("properties.vector_int8.index_options.type", () -> mappings).get(null).toString().equals("int8_hnsw")
940+
);
941+
assertTrue(new WriteField("properties.vector_bbq", () -> mappings).exists());
942+
assertTrue(new WriteField("properties.vector_bbq.index_options.type", () -> mappings).get(null).toString().equals("bbq_hnsw"));
943+
});
936944
}
937945

938946
public void testBBQDynamicMappingWhenFirstIngestingDoc() throws Exception {
@@ -954,14 +962,19 @@ public void testBBQDynamicMappingWhenFirstIngestingDoc() throws Exception {
954962
assertTrue(new WriteField("properties.vector", () -> mappings).exists());
955963
assertFalse(new WriteField("properties.vector.index_options.type", () -> mappings).exists());
956964

957-
client().index(new IndexRequest("test").source("vector", Randomness.get().doubles(BBQ_DIMS_DEFAULT_THRESHOLD, 0.0, 5.0).toArray()))
958-
.get();
959-
Map<String, Object> updatedMappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
960-
.get()
961-
.mappings()
962-
.get("test")
963-
.sourceAsMap();
964-
assertTrue(new WriteField("properties.vector", () -> updatedMappings).exists());
965-
assertTrue(new WriteField("properties.vector.index_options.type", () -> updatedMappings).get(null).toString().equals("bbq_hnsw"));
965+
client().index(
966+
new IndexRequest("test").source("vector", Randomness.get().doubles(BBQ_DIMS_DEFAULT_THRESHOLD, 0.0, 5.0).toArray())
967+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
968+
).get();
969+
970+
assertBusy(() -> {
971+
Map<String, Object> updatedMappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
972+
.get()
973+
.mappings()
974+
.get("test")
975+
.sourceAsMap();
976+
assertTrue(new WriteField("properties.vector", () -> updatedMappings).exists());
977+
assertTrue(new WriteField("properties.vector.index_options.type", () -> updatedMappings).get("").toString().equals("bbq_hnsw"));
978+
});
966979
}
967980
}

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ static TransportVersion def(int id) {
314314
public static final TransportVersion ML_INFERENCE_CUSTOM_SERVICE_INPUT_TYPE = def(9_105_0_00);
315315
public static final TransportVersion ML_INFERENCE_SAGEMAKER_ELASTIC = def(9_106_0_00);
316316
public static final TransportVersion SPARSE_VECTOR_FIELD_PRUNING_OPTIONS = def(9_107_0_00);
317+
public static final TransportVersion CLUSTER_STATE_PROJECTS_SETTINGS = def(9_108_0_00);
317318

318319
/*
319320
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/cluster/ClusterModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.cluster.metadata.RepositoriesMetadata;
2929
import org.elasticsearch.cluster.metadata.StreamsMetadata;
3030
import org.elasticsearch.cluster.project.ProjectResolver;
31+
import org.elasticsearch.cluster.project.ProjectStateRegistry;
3132
import org.elasticsearch.cluster.routing.DelayedAllocationService;
3233
import org.elasticsearch.cluster.routing.ShardRouting;
3334
import org.elasticsearch.cluster.routing.ShardRoutingRoleStrategy;
@@ -292,6 +293,7 @@ public static List<Entry> getNamedWriteables() {
292293
RegisteredPolicySnapshots::new,
293294
RegisteredPolicySnapshots.RegisteredSnapshotsDiff::new
294295
);
296+
registerClusterCustom(entries, ProjectStateRegistry.TYPE, ProjectStateRegistry::new, ProjectStateRegistry::readDiffFrom);
295297
// Secrets
296298
registerClusterCustom(entries, ClusterSecrets.TYPE, ClusterSecrets::new, ClusterSecrets::readDiffFrom);
297299
registerProjectCustom(entries, ProjectSecrets.TYPE, ProjectSecrets::new, ProjectSecrets::readDiffFrom);

server/src/main/java/org/elasticsearch/cluster/ClusterState.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ public Builder(ClusterState state) {
10471047
public Builder(ClusterName clusterName) {
10481048
this.compatibilityVersions = new HashMap<>();
10491049
this.nodeFeatures = new HashMap<>();
1050-
customs = ImmutableOpenMap.builder();
1050+
this.customs = ImmutableOpenMap.builder();
10511051
this.clusterName = clusterName;
10521052
}
10531053

@@ -1330,7 +1330,6 @@ public void writeTo(StreamOutput out) throws IOException {
13301330
}
13311331

13321332
private static class ClusterStateDiff implements Diff<ClusterState> {
1333-
13341333
private final long toVersion;
13351334

13361335
private final String fromUuid;

server/src/main/java/org/elasticsearch/cluster/ProjectState.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
import org.elasticsearch.cluster.block.ClusterBlocks;
1313
import org.elasticsearch.cluster.metadata.ProjectId;
1414
import org.elasticsearch.cluster.metadata.ProjectMetadata;
15+
import org.elasticsearch.cluster.project.ProjectStateRegistry;
1516
import org.elasticsearch.cluster.routing.RoutingTable;
1617
import org.elasticsearch.common.Strings;
18+
import org.elasticsearch.common.settings.Settings;
1719

1820
import java.util.Objects;
1921
import java.util.function.Consumer;
@@ -26,6 +28,7 @@ public final class ProjectState {
2628
private final ClusterState cluster;
2729
private final ProjectId project;
2830
private final ProjectMetadata projectMetadata;
31+
private final Settings projectSettings;
2932
private final RoutingTable routingTable;
3033

3134
ProjectState(ClusterState clusterState, ProjectId projectId) {
@@ -34,6 +37,7 @@ public final class ProjectState {
3437
this.cluster = clusterState;
3538
this.project = projectId;
3639
this.projectMetadata = clusterState.metadata().getProject(projectId);
40+
this.projectSettings = ProjectStateRegistry.getProjectSettings(projectId, clusterState);
3741
this.routingTable = clusterState.routingTable(projectId);
3842
}
3943

@@ -57,6 +61,10 @@ public ClusterBlocks blocks() {
5761
return cluster().blocks();
5862
}
5963

64+
public Settings settings() {
65+
return projectSettings;
66+
}
67+
6068
@Override
6169
public boolean equals(Object obj) {
6270
if (obj == this) return true;

server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,7 @@ private MetadataDiff(StreamInput in) throws IOException {
985985
RESERVED_DIFF_VALUE_READER
986986
);
987987

988-
singleProject = new ProjectMetadata.ProjectMetadataDiff(
989-
indices,
990-
templates,
991-
projectCustoms,
992-
DiffableUtils.emptyDiff(),
993-
Settings.EMPTY_DIFF
994-
);
988+
singleProject = new ProjectMetadata.ProjectMetadataDiff(indices, templates, projectCustoms, DiffableUtils.emptyDiff());
995989
multiProject = null;
996990
} else {
997991
fromNodeBeforeMultiProjectsSupport = false;

0 commit comments

Comments
 (0)