Allow index requests with explicit ids on seq_no disabled backing indices#144041
Conversation
When sequence numbers are disabled on a data stream backing index, OCC (if_seq_no/if_primary_term) cannot be used. This relaxes the append-only restriction for INDEX ops with an explicit document ID targeting backing indices where seq_no is disabled, either on the target index itself or on any sibling backing index in the data stream.
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| } | ||
|
|
||
| static boolean hasAnyBackingIndexWithSeqNoDisabled(DataStream dataStream, Function<Index, IndexMetadata> indexMetadataProvider) { | ||
| for (Index backingIndex : dataStream.getIndices()) { |
There was a problem hiding this comment.
I'm exploring the idea of adding a flag into the data stream to tell whether or not it has any backing index with disabled seq nos.
…q-no-disabled-backing-indices
|
|
||
| @After | ||
| public void resetSearchInterceptor() { | ||
| public void cleanupInterceptors() { |
There was a problem hiding this comment.
I hit a failure in CI with this test and I noticed that the request interceptors weren't cleared after each test, so I went ahead and restricted more when we add the assertions based on the index name and added the clearing between runs to avoid any issues. Happy to extract this into another PR if it's adding noise.
| // to handle mixed data streams where OCC is disabled for the entire operation. | ||
| if (writeRequest.id() != null && IndexSettings.DISABLE_SEQUENCE_NUMBERS_FEATURE_FLAG) { | ||
| IndexMetadata targetMetadata = indexMetadataProvider.apply(indexAbstraction.getWriteIndex()); | ||
| if ((targetMetadata != null && IndexSettings.DISABLE_SEQUENCE_NUMBERS.get(targetMetadata.getSettings())) |
There was a problem hiding this comment.
I think we can use targetMetadata.sequenceNumbersDisabled() here? That would be much more efficient.
| static boolean hasAnyBackingIndexWithSeqNoDisabled(DataStream dataStream, Function<Index, IndexMetadata> indexMetadataProvider) { | ||
| for (Index backingIndex : dataStream.getIndices()) { | ||
| IndexMetadata im = indexMetadataProvider.apply(backingIndex); | ||
| if (im != null && IndexSettings.DISABLE_SEQUENCE_NUMBERS.get(im.getSettings())) { |
| var overwriteResponse = client().prepareBulk() | ||
| .add(prepareIndex(backingIndex).setId(createdId).setSource(Map.of("@timestamp", "2020-01-01", "value", "overwritten"))) | ||
| .get(); | ||
| assertNoFailures(overwriteResponse); |
There was a problem hiding this comment.
Should we assert the UPDATED status?
|
|
||
| @After | ||
| public void resetSearchInterceptor() { | ||
| public void cleanupInterceptors() { |
…q-no-disabled-backing-indices
|
Thanks for the review Tanguy! |
…ices (elastic#144041) When sequence numbers are disabled on a data stream backing index, OCC (if_seq_no/if_primary_term) cannot be used. This relaxes the append-only restriction for INDEX ops with an explicit document ID targeting backing indices where seq_no is disabled, either on the target index itself or on any sibling backing index in the data stream. Relates elastic#136305
When sequence numbers are disabled on a data stream backing index,
OCC (if_seq_no/if_primary_term) cannot be used. This relaxes the
append-only restriction for INDEX ops with an explicit document id
targeting backing indices where seq_no is disabled, either on the
target index itself or on any sibling backing index in the data stream.