-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Preserve backing index ordering for data streams #63749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve backing index ordering for data streams #63749
Conversation
Pinging @elastic/es-core-features (:Core/Features/Indices APIs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (assuming CI is green), thanks Dan!
I left suggestion for refactoring in test but it can be ignored.
backingIndices.add(createIndexMetadata("not-in-order-2", true)); | ||
backingIndices.add(createIndexMetadata("not-in-order-1", true)); | ||
backingIndices.add(createIndexMetadata(DataStream.getDefaultBackingIndexName(dataStreamName, 3), true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backingIndices.add(createIndexMetadata("not-in-order-2", true)); | |
backingIndices.add(createIndexMetadata("not-in-order-1", true)); | |
backingIndices.add(createIndexMetadata(DataStream.getDefaultBackingIndexName(dataStreamName, 3), true)); | |
String[] names = new String[]{"not-in-order-2", "not-in-order-1", DataStream.getDefaultBackingIndexName(dataStreamName, 3)}; | |
List<IndexMetadata> backingIndices = Arrays.stream(names).map(n -> createIndexMetadata(n, true)).collect(Collectors.toList()); |
assertThat(dataStreams.get(0).getBackingIndices().length, equalTo(3)); | ||
assertThat(dataStreams.get(0).getBackingIndices()[0], equalTo(backingIndices.get(0).getIndex().getName())); | ||
assertThat(dataStreams.get(0).getBackingIndices()[1], equalTo(backingIndices.get(1).getIndex().getName())); | ||
assertThat(dataStreams.get(0).getBackingIndices()[2], equalTo(backingIndices.get(2).getIndex().getName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertThat(dataStreams.get(0).getBackingIndices().length, equalTo(3)); | |
assertThat(dataStreams.get(0).getBackingIndices()[0], equalTo(backingIndices.get(0).getIndex().getName())); | |
assertThat(dataStreams.get(0).getBackingIndices()[1], equalTo(backingIndices.get(1).getIndex().getName())); | |
assertThat(dataStreams.get(0).getBackingIndices()[2], equalTo(backingIndices.get(2).getIndex().getName())); | |
assertThat(dataStreams.get(0).getBackingIndices(), arrayContaining(names)); |
Thanks, @probakowski! I took your suggestions for simplifying the test. |
The resolve index API incorrectly sorts the backing indices returned for data streams. The backing indices on a data stream are an ordered list in which the last index is always the write index so sorting them may produce incorrect results once migration of existing indices to data streams is permitted.