Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/reference/indices/shard-stores.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ The API returns the following response:
"roles": [...],
"version": "8.10.0",
"min_index_version": 7000099,
"min_read_only_index_version": 7000099,
"max_index_version": 8100099
},
"allocation_id": "2iNySv_OQVePRX-yaRH_lQ", <4>
Expand All @@ -193,6 +194,7 @@ The API returns the following response:
// TESTRESPONSE[s/"roles": \[[^]]*\]/"roles": $body.$_path/]
// TESTRESPONSE[s/"8.10.0"/\$node_version/]
// TESTRESPONSE[s/"min_index_version": 7000099/"min_index_version": $body.$_path/]
// TESTRESPONSE[s/"min_index_version": 7000099/"min_index_version": $body.$_path/]
// TESTRESPONSE[s/"max_index_version": 8100099/"max_index_version": $body.$_path/]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ static TransportVersion def(int id) {
public static final TransportVersion SEMANTIC_QUERY_LENIENT = def(8_807_00_0);
public static final TransportVersion ESQL_QUERY_BUILDER_IN_SEARCH_FUNCTIONS = def(8_808_00_0);
public static final TransportVersion EQL_ALLOW_PARTIAL_SEARCH_RESULTS = def(8_809_00_0);
public static final TransportVersion NODE_VERSION_INFORMATION_WITH_MIN_READ_ONLY_INDEX_VERSION = def(8_810_00_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.SortedSet;
import java.util.TreeSet;

import static org.elasticsearch.TransportVersions.NODE_VERSION_INFORMATION_WITH_MIN_READ_ONLY_INDEX_VERSION;
import static org.elasticsearch.node.NodeRoleSettings.NODE_ROLES_SETTING;

/**
Expand Down Expand Up @@ -339,7 +340,16 @@ public DiscoveryNode(StreamInput in) throws IOException {
}
this.roles = Collections.unmodifiableSortedSet(roles);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) {
versionInfo = new VersionInformation(Version.readVersion(in), IndexVersion.readVersion(in), IndexVersion.readVersion(in));
Version version = Version.readVersion(in);
IndexVersion minIndexVersion = IndexVersion.readVersion(in);
IndexVersion minReadOnlyIndexVersion;
if (in.getTransportVersion().onOrAfter(NODE_VERSION_INFORMATION_WITH_MIN_READ_ONLY_INDEX_VERSION)) {
minReadOnlyIndexVersion = IndexVersion.readVersion(in);
} else {
minReadOnlyIndexVersion = minIndexVersion;
}
IndexVersion maxIndexVersion = IndexVersion.readVersion(in);
versionInfo = new VersionInformation(version, minIndexVersion, minReadOnlyIndexVersion, maxIndexVersion);
} else {
versionInfo = inferVersionInformation(Version.readVersion(in));
}
Expand Down Expand Up @@ -378,6 +388,9 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) {
Version.writeVersion(versionInfo.nodeVersion(), out);
IndexVersion.writeVersion(versionInfo.minIndexVersion(), out);
if (out.getTransportVersion().onOrAfter(NODE_VERSION_INFORMATION_WITH_MIN_READ_ONLY_INDEX_VERSION)) {
IndexVersion.writeVersion(versionInfo.minReadOnlyIndexVersion(), out);
}
IndexVersion.writeVersion(versionInfo.maxIndexVersion(), out);
} else {
Version.writeVersion(versionInfo.nodeVersion(), out);
Expand Down Expand Up @@ -504,6 +517,10 @@ public IndexVersion getMinIndexVersion() {
return versionInfo.minIndexVersion();
}

public IndexVersion getMinReadOnlyIndexVersion() {
return versionInfo.minReadOnlyIndexVersion();
}

public IndexVersion getMaxIndexVersion() {
return versionInfo.maxIndexVersion();
}
Expand Down Expand Up @@ -603,6 +620,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.endArray();
builder.field("version", versionInfo.nodeVersion());
builder.field("min_index_version", versionInfo.minIndexVersion());
builder.field("min_read_only_index_version", versionInfo.minReadOnlyIndexVersion());
builder.field("max_index_version", versionInfo.maxIndexVersion());
builder.endObject();
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode>, SimpleDiffable<D
private final Version minNodeVersion;
private final IndexVersion maxDataNodeCompatibleIndexVersion;
private final IndexVersion minSupportedIndexVersion;
private final IndexVersion minReadOnlySupportedIndexVersion;

private final Map<String, Set<String>> tiersToNodeIds;

Expand All @@ -86,6 +87,7 @@ private DiscoveryNodes(
Version minNodeVersion,
IndexVersion maxDataNodeCompatibleIndexVersion,
IndexVersion minSupportedIndexVersion,
IndexVersion minReadOnlySupportedIndexVersion,
Map<String, Set<String>> tiersToNodeIds
) {
this.nodeLeftGeneration = nodeLeftGeneration;
Expand All @@ -103,6 +105,8 @@ private DiscoveryNodes(
this.maxNodeVersion = maxNodeVersion;
this.maxDataNodeCompatibleIndexVersion = maxDataNodeCompatibleIndexVersion;
this.minSupportedIndexVersion = minSupportedIndexVersion;
this.minReadOnlySupportedIndexVersion = minReadOnlySupportedIndexVersion;
assert minReadOnlySupportedIndexVersion.onOrBefore(minSupportedIndexVersion);
assert (localNodeId == null) == (localNode == null);
this.tiersToNodeIds = tiersToNodeIds;
}
Expand All @@ -122,6 +126,7 @@ public DiscoveryNodes withMasterNodeId(@Nullable String masterNodeId) {
minNodeVersion,
maxDataNodeCompatibleIndexVersion,
minSupportedIndexVersion,
minReadOnlySupportedIndexVersion,
tiersToNodeIds
);
}
Expand Down Expand Up @@ -382,6 +387,13 @@ public IndexVersion getMinSupportedIndexVersion() {
return minSupportedIndexVersion;
}

/**
* Returns the minimum index version for read-only indices supported by all nodes in the cluster
*/
public IndexVersion getMinReadOnlySupportedIndexVersion() {
return minReadOnlySupportedIndexVersion;
}

/**
* Return the node-left generation, which is the number of times the cluster membership has been updated by removing one or more nodes.
* <p>
Expand Down Expand Up @@ -841,6 +853,7 @@ public DiscoveryNodes build() {
Version minNonClientNodeVersion = null;
IndexVersion maxDataNodeCompatibleIndexVersion = null;
IndexVersion minSupportedIndexVersion = null;
IndexVersion minReadOnlySupportedIndexVersion = null;
for (Map.Entry<String, DiscoveryNode> nodeEntry : nodes.entrySet()) {
DiscoveryNode discoNode = nodeEntry.getValue();
Version version = discoNode.getVersion();
Expand All @@ -851,6 +864,7 @@ public DiscoveryNodes build() {
minNodeVersion = min(minNodeVersion, version);
maxNodeVersion = max(maxNodeVersion, version);
minSupportedIndexVersion = max(minSupportedIndexVersion, discoNode.getMinIndexVersion());
minReadOnlySupportedIndexVersion = max(minReadOnlySupportedIndexVersion, discoNode.getMinReadOnlyIndexVersion());
}

final long newNodeLeftGeneration;
Expand Down Expand Up @@ -884,6 +898,7 @@ public DiscoveryNodes build() {
Objects.requireNonNullElse(minNodeVersion, Version.CURRENT.minimumCompatibilityVersion()),
Objects.requireNonNullElse(maxDataNodeCompatibleIndexVersion, IndexVersion.current()),
Objects.requireNonNullElse(minSupportedIndexVersion, IndexVersions.MINIMUM_COMPATIBLE),
Objects.requireNonNullElse(minReadOnlySupportedIndexVersion, IndexVersions.MINIMUM_READONLY_COMPATIBLE),
computeTiersToNodesMap(dataNodes)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@

/**
* Represents the versions of various aspects of an Elasticsearch node.
* @param nodeVersion The node {@link Version}
* @param minIndexVersion The minimum {@link IndexVersion} supported by this node
* @param maxIndexVersion The maximum {@link IndexVersion} supported by this node
* @param nodeVersion The node {@link Version}
* @param minIndexVersion The minimum {@link IndexVersion} supported by this node
* @param minReadOnlyIndexVersion The minimum {@link IndexVersion} for read-only indices supported by this node
* @param maxIndexVersion The maximum {@link IndexVersion} supported by this node
*/
public record VersionInformation(Version nodeVersion, IndexVersion minIndexVersion, IndexVersion maxIndexVersion) {
public record VersionInformation(
Version nodeVersion,
IndexVersion minIndexVersion,
IndexVersion minReadOnlyIndexVersion,
IndexVersion maxIndexVersion
) {

public static final VersionInformation CURRENT = new VersionInformation(
Version.CURRENT,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current()
);

Expand All @@ -45,9 +52,16 @@ public static VersionInformation inferVersions(Version nodeVersion) {
}
}

@Deprecated
public VersionInformation(Version version, IndexVersion minIndexVersion, IndexVersion maxIndexVersion) {
this(version, minIndexVersion, minIndexVersion, maxIndexVersion);
}

public VersionInformation {
Objects.requireNonNull(nodeVersion);
Objects.requireNonNull(minIndexVersion);
Objects.requireNonNull(minReadOnlyIndexVersion);
Objects.requireNonNull(maxIndexVersion);
assert minReadOnlyIndexVersion.onOrBefore(minIndexVersion) : minReadOnlyIndexVersion + " > " + minIndexVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void openProbeConnection(ActionListener<Transport.Connection> listener)
new VersionInformation(
Version.CURRENT.minimumCompatibilityVersion(),
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current()
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ private static IndexVersion def(int id, Version luceneVersion) {
*/

public static final IndexVersion MINIMUM_COMPATIBLE = V_7_0_0;
public static final IndexVersion MINIMUM_READONLY_COMPATIBLE = MINIMUM_COMPATIBLE;

static final NavigableMap<Integer, IndexVersion> VERSION_IDS = getAllVersionIds(IndexVersions.class);
static final IndexVersion LATEST_DEFINED;
Expand All @@ -193,7 +194,7 @@ static NavigableMap<Integer, IndexVersion> getAllVersionIds(Class<?> cls) {
Map<Integer, String> versionIdFields = new HashMap<>();
NavigableMap<Integer, IndexVersion> builder = new TreeMap<>();

Set<String> ignore = Set.of("ZERO", "MINIMUM_COMPATIBLE");
Set<String> ignore = Set.of("ZERO", "MINIMUM_COMPATIBLE", "MINIMUM_READONLY_COMPATIBLE");

for (Field declaredField : cls.getFields()) {
if (declaredField.getType().equals(IndexVersion.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public void onFailure(Exception e) {
new VersionInformation(
Version.CURRENT.minimumCompatibilityVersion(),
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ private static DiscoveryNode resolveSeedNode(String clusterAlias, String address
var seedVersion = new VersionInformation(
Version.CURRENT.minimumCompatibilityVersion(),
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current()
);
if (proxyAddress == null || proxyAddress.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void testToXContentWithDeprecatedClusterState() {
],
"version": "%s",
"min_index_version": %s,
"min_read_only_index_version": %s,
"max_index_version": %s
}
},
Expand Down Expand Up @@ -219,6 +220,7 @@ public void testToXContentWithDeprecatedClusterState() {
clusterState.getNodes().get("node0").getEphemeralId(),
Version.CURRENT,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current(),
IndexVersion.current(),
IndexVersion.current()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public void testToXContent() throws IOException {
],
"version": "%s",
"min_index_version":%s,
"min_read_only_index_version":%s,
"max_index_version":%s
}
},
Expand Down Expand Up @@ -389,6 +390,7 @@ public void testToXContent() throws IOException {
ephemeralId,
Version.CURRENT,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current(),
TransportVersion.current(),
IndexVersion.current(),
Expand Down Expand Up @@ -488,6 +490,7 @@ public void testToXContent_FlatSettingTrue_ReduceMappingFalse() throws IOExcepti
],
"version" : "%s",
"min_index_version" : %s,
"min_read_only_index_version" : %s,
"max_index_version" : %s
}
},
Expand Down Expand Up @@ -663,6 +666,7 @@ public void testToXContent_FlatSettingTrue_ReduceMappingFalse() throws IOExcepti
ephemeralId,
Version.CURRENT,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current(),
TransportVersion.current(),
IndexVersion.current(),
Expand Down Expand Up @@ -762,6 +766,7 @@ public void testToXContent_FlatSettingFalse_ReduceMappingTrue() throws IOExcepti
],
"version" : "%s",
"min_index_version" : %s,
"min_read_only_index_version" : %s,
"max_index_version" : %s
}
},
Expand Down Expand Up @@ -943,6 +948,7 @@ public void testToXContent_FlatSettingFalse_ReduceMappingTrue() throws IOExcepti
ephemeralId,
Version.CURRENT,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current(),
TransportVersion.current(),
IndexVersion.current(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import static java.util.Collections.emptySet;
import static org.elasticsearch.test.NodeRoles.nonRemoteClusterClientNode;
import static org.elasticsearch.test.NodeRoles.remoteClusterClientNode;
import static org.elasticsearch.test.TransportVersionUtils.getPreviousVersion;
import static org.elasticsearch.test.TransportVersionUtils.randomVersionBetween;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -221,13 +223,15 @@ public void testDiscoveryNodeToXContent() {
],
"version" : "%s",
"min_index_version" : %s,
"min_read_only_index_version" : %s,
"max_index_version" : %s
}
}""",
transportAddress,
withExternalId ? "test-external-id" : "test-name",
Version.CURRENT,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersion.current()
)
)
Expand All @@ -250,4 +254,61 @@ public void testDiscoveryNodeToString() {
assertThat(toString, containsString("{" + node.getVersion() + "}"));
assertThat(toString, containsString("{test-attr=val}"));// attributes
}

public void testDiscoveryNodeMinReadOnlyVersionSerialization() throws Exception {
var node = DiscoveryNodeUtils.create("_id", buildNewFakeTransportAddress(), Version.CURRENT);

{
try (var out = new BytesStreamOutput()) {
out.setTransportVersion(TransportVersion.current());
node.writeTo(out);

try (var in = StreamInput.wrap(out.bytes().array())) {
in.setTransportVersion(TransportVersion.current());

var deserialized = new DiscoveryNode(in);
assertThat(deserialized.getId(), equalTo(node.getId()));
assertThat(deserialized.getAddress(), equalTo(node.getAddress()));
assertThat(deserialized.getMinIndexVersion(), equalTo(node.getMinIndexVersion()));
assertThat(deserialized.getMaxIndexVersion(), equalTo(node.getMaxIndexVersion()));
assertThat(deserialized.getMinReadOnlyIndexVersion(), equalTo(node.getMinReadOnlyIndexVersion()));
assertThat(deserialized.getVersionInformation(), equalTo(node.getVersionInformation()));
}
}
}

{
var oldVersion = randomVersionBetween(
random(),
TransportVersions.MINIMUM_COMPATIBLE,
getPreviousVersion(TransportVersions.NODE_VERSION_INFORMATION_WITH_MIN_READ_ONLY_INDEX_VERSION)
);
try (var out = new BytesStreamOutput()) {
out.setTransportVersion(oldVersion);
node.writeTo(out);

try (var in = StreamInput.wrap(out.bytes().array())) {
in.setTransportVersion(oldVersion);

var deserialized = new DiscoveryNode(in);
assertThat(deserialized.getId(), equalTo(node.getId()));
assertThat(deserialized.getAddress(), equalTo(node.getAddress()));
assertThat(deserialized.getMinIndexVersion(), equalTo(node.getMinIndexVersion()));
assertThat(deserialized.getMaxIndexVersion(), equalTo(node.getMaxIndexVersion()));
assertThat(deserialized.getMinReadOnlyIndexVersion(), equalTo(node.getMinIndexVersion()));
assertThat(
deserialized.getVersionInformation(),
equalTo(
new VersionInformation(
node.getVersion(),
node.getMinIndexVersion(),
node.getMinIndexVersion(),
node.getMaxIndexVersion()
)
)
);
}
}
}
}
}
Loading