Add explicit isNoOpUpdate() method to MapperService#144113
Add explicit isNoOpUpdate() method to MapperService#144113elasticsearchmachine merged 7 commits intoelastic:mainfrom
Conversation
We currently check that a mapping update will be applied and that it is not a no-op by calling MapperService.merge() with a special merge reason. All other calls to merge() will update the state of the MapperService, but this just does preflight checks. This can be confusing when reading code - it's not necessarily obvious if a call to merge() is going to change state or not. To make this clearer, we separate preflight checks that don't change state, and real merges that do change state, into separate method calls.
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
|
@drempapis would appreciate your eyes on this, given the fix you merged this morning! |
| } | ||
|
|
||
| private DocumentMapper doMerge(String type, MergeReason reason, Map<String, Object> mappingSourceAsMap) { | ||
| assert reason != MergeReason.MAPPING_AUTO_UPDATE_PREFLIGHT; |
There was a problem hiding this comment.
Is this assert enough? Should it be replaced by a runtime check, throwing an exception?
There was a problem hiding this comment.
An assertion should be fine I think, MergeReason is entirely internal.
| // returning the current document mapper as the merge result to simulate a noop mapping update | ||
| when(mapperService.documentMapper()).thenReturn(documentMapper); | ||
| when(mapperService.merge(any(), any(CompressedXContent.class), any())).thenReturn(documentMapper); | ||
| when(mapperService.isNoOpUpdate(any())).thenReturn(true); |
There was a problem hiding this comment.
That behavior already existed, but I think we should remove the mockito framework.
There was a problem hiding this comment.
Yep, good idea. There are several tests in here that use Mockito so I think probably it's best done as a follow-up covering all of them, to keep things separate?
There was a problem hiding this comment.
Yes, this should be done in a follow-up pr
…elocations * upstream/main: (33 commits) Unmute InferenceRestIT and DefaultEndPointsIT (elastic#144217) feat: add keep_alive to async task status (elastic#144010) Add explicit isNoOpUpdate() method to MapperService (elastic#144113) Always attach APM Agent (elastic#144120) Fix random_score nightly tests (elastic#144176) Add nested query checks for disabled sequence numbers (elastic#144185) Return sentinel values from Fetch when sequence numbers are disabled (elastic#144212) [Test] Test peer-recovery with sequence numbers pruning (elastic#144116) Remove `scaled-*` field assertions from mixed cluster downsampling test (elastic#144295) Refactor: Use range syntax in ES|QL exponential histogram tests (elastic#144110) Move resolve aliases to IndexAbstractionOptions (elastic#143953) unmute test (elastic#144299) Fix approximation csvtests (elastic#144233) fix test (elastic#144171) Add int4 vector scoring benchmarks (elastic#144105) Mute org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT test elastic#143023 Mute org.elasticsearch.test.apmintegration.MetricsApmIT testApmIntegration {withOTel=false} elastic#144282 Native cli launcher (elastic#143712) Mute org.elasticsearch.xpack.esql.qa.multi_node.GenerativeIT test elastic#143023 Mute org.elasticsearch.xpack.esql.heap_attack.HeapAttackSubqueryIT testManyRandomKeywordFieldsInSubqueryIntermediateResults elastic#144274 ...
We currently check that a mapping update will be applied and that it is not a no-op by calling MapperService.merge() with a special merge reason. All other calls to merge() will update the state of the MapperService, but this just does preflight checks. This can be confusing when reading code - it's not necessarily obvious if a call to merge() is going to change state or not. To make this clearer, we separate preflight checks that don't change state, and real merges that do change state, into separate method calls.
We currently check that a mapping update will be applied and that it is not a no-op by calling MapperService.merge() with a special merge reason. All other calls to merge() will update the state of the MapperService, but this just does preflight checks. This can be confusing when reading code - it's not necessarily obvious if a call to merge() is going to change state or not. To make this clearer, we separate preflight checks that don't change state, and real merges that do change state, into separate method calls.