Load FieldInfos from store if not yet initialised through a refresh on IndexShard#125650
Load FieldInfos from store if not yet initialised through a refresh on IndexShard#125650original-brownbear merged 6 commits intoelastic:mainfrom original-brownbear:125483
Conversation
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
|
Hi @original-brownbear, I've created a changelog YAML for you. |
piergm
left a comment
There was a problem hiding this comment.
LGTM! Thanks @original-brownbear for working on this :D
| try (Engine.Searcher hasValueSearcher = getEngine().acquireSearcher("field_has_value")) { | ||
| return FieldInfos.getMergedFieldInfos(hasValueSearcher.getIndexReader()); | ||
| } catch (AlreadyClosedException ignore) { | ||
| // engine is closed - no update to3 FieldInfos is fine |
There was a problem hiding this comment.
lol right and in the process of fixing grammar/typo no less 🤣 thanks!
andreidan
left a comment
There was a problem hiding this comment.
LGTM too :) Thanks for fixing this Armin
|
|
||
| static { | ||
| try { | ||
| FIELD_INFOS = MethodHandles.lookup().findVarHandle(IndexShard.class, "fieldInfos", FieldInfos.class); |
There was a problem hiding this comment.
Ah this is a bit I don't like about VarHandle, and I'd normally prefer an Atomic... for the CAS operation for readability.
However, the tradeoff here is pretty sweet as we avoid creating (a potential alternative) one Atomic... instance for every IndexShard in order to wrap the fieldInfos giving us a sweet memory saving.
Nicely done ! :)
|
Thanks you two! |
…n IndexShard (#125650) (#125703) Load field caps from store if they haven't been initialised through a refresh yet. Keep the plain reads to not mess with performance characteristics too much on the good path but protect against confusing races when loading field infos now (that probably should have been ordered stores in the first place but this was safe due to other locks/volatiles on the refresh path). Closes #125483
…n IndexShard (#125650) (#125704) Load field caps from store if they haven't been initialised through a refresh yet. Keep the plain reads to not mess with performance characteristics too much on the good path but protect against confusing races when loading field infos now (that probably should have been ordered stores in the first place but this was safe due to other locks/volatiles on the refresh path). Closes #125483
|
Thanks for fixing @original-brownbear I believe it makes sense to backport this to 8.18 as well. |
|
incoming in #125762 :) |
…n IndexShard (#125650) (#125762) Load field caps from store if they haven't been initialised through a refresh yet. Keep the plain reads to not mess with performance characteristics too much on the good path but protect against confusing races when loading field infos now (that probably should have been ordered stores in the first place but this was safe due to other locks/volatiles on the refresh path). Closes #125483
|
|
||
| // check that field_caps empty field filtering works as well | ||
| FieldCapabilitiesResponse response = client().prepareFieldCaps(mountedIndices).setFields("*").setincludeEmptyFields(false).get(); | ||
| assertNotNull(response.getField("keyword")); |
There was a problem hiding this comment.
I wonder if it makes sense to add the same test to the N-2 indices related tests for indices that are imported as verified read-only. We know the fix addresses the same issue for them too, but it'd be safer to have a specific test for them? These tests are under qa/lucene-index-compatibility .
There was a problem hiding this comment.
++ definitely. Let me try something, maybe I can get the full field caps suite running for searchable snapshots and there somehow, would be really nice to have coverage across all the implementations that play tricks on the engine :)
…n IndexShard (elastic#125650) Load field caps from store if they haven't been initialised through a refresh yet. Keep the plain reads to not mess with performance characteristics too much on the good path but protect against confusing races when loading field infos now (that probably should have been ordered stores in the first place but this was safe due to other locks/volatiles on the refresh path). Closes elastic#125483
…ndomIOExceptionsIT.testRandomDirectoryIOExceptions (#146240) assertSearcherIsWarmedUp() asserts that the external reader has been warmed up before being accessed for searches, except for specific cases like gatherings segments stats or segments infos in which accessing a non-warmed up external reader are allowed. This assertion started to trip more frequently two weeks ago in the SearchWithRandomIOExceptionsIT testRandomDirectoryIOExceptions, causing the test to be muted on the main branch. The assertion fails when a random IO exception is thrown on purpose by the test during a refresh. Then the ExternalReaderManager is not warmed up and its isWarmedUp flag remains false. But Lucene's ReferenceManager always calls the afterRefresh() method on refresh listeners, and in the case of RefreshFieldHasValueListener it triggered loadFieldInfos() since fieldInfos was null. loadFieldInfos() than called acquireSearcher("field_has_value") before warm-up, failing the assertion. In this change the condition fieldInfos == null is removed from the RefreshFieldHasValueListener.afterRefresh() method in order to avoid calling loadFieldInfos() on a failed refresh. It should be ok since getFieldInfos() already handles lazy loading when fieldInfos is null. I also think we should relax the assertion in assertSearcherIsWarmedUp() to allow FIELD_HAS_VALUE_SOURCE, so that if something like the Field Capabilities API calls loadFieldInfos()/getFieldInfos() before warm-up the assertion won't fail. I would expect that accessing FieldInfos is safe before warm-up, similar to segment stats/infos. Relates #118733 Note: the assertion also tripped for that same test soon after it was refactored in #125650, causing the same test to fail on 8.x branch (8.16, then 8.17 at the time) in a different manner documented here that I'll address in a follow up.
…ndomIOExceptionsIT.testRandomDirectoryIOExceptions (elastic#146240) assertSearcherIsWarmedUp() asserts that the external reader has been warmed up before being accessed for searches, except for specific cases like gatherings segments stats or segments infos in which accessing a non-warmed up external reader are allowed. This assertion started to trip more frequently two weeks ago in the SearchWithRandomIOExceptionsIT testRandomDirectoryIOExceptions, causing the test to be muted on the main branch. The assertion fails when a random IO exception is thrown on purpose by the test during a refresh. Then the ExternalReaderManager is not warmed up and its isWarmedUp flag remains false. But Lucene's ReferenceManager always calls the afterRefresh() method on refresh listeners, and in the case of RefreshFieldHasValueListener it triggered loadFieldInfos() since fieldInfos was null. loadFieldInfos() than called acquireSearcher("field_has_value") before warm-up, failing the assertion. In this change the condition fieldInfos == null is removed from the RefreshFieldHasValueListener.afterRefresh() method in order to avoid calling loadFieldInfos() on a failed refresh. It should be ok since getFieldInfos() already handles lazy loading when fieldInfos is null. I also think we should relax the assertion in assertSearcherIsWarmedUp() to allow FIELD_HAS_VALUE_SOURCE, so that if something like the Field Capabilities API calls loadFieldInfos()/getFieldInfos() before warm-up the assertion won't fail. I would expect that accessing FieldInfos is safe before warm-up, similar to segment stats/infos. Relates elastic#118733 Note: the assertion also tripped for that same test soon after it was refactored in elastic#125650, causing the same test to fail on 8.x branch (8.16, then 8.17 at the time) in a different manner documented here that I'll address in a follow up. # Conflicts: # muted-tests.yml
…ndomIOExceptionsIT.testRandomDirectoryIOExceptions (elastic#146240) Backport of elastic#146240 for 9.3 assertSearcherIsWarmedUp() asserts that the external reader has been warmed up before being accessed for searches, except for specific cases like gatherings segments stats or segments infos in which accessing a non-warmed up external reader are allowed. This assertion started to trip more frequently two weeks ago in the SearchWithRandomIOExceptionsIT testRandomDirectoryIOExceptions, causing the test to be muted on the main branch. The assertion fails when a random IO exception is thrown on purpose by the test during a refresh. Then the ExternalReaderManager is not warmed up and its isWarmedUp flag remains false. But Lucene's ReferenceManager always calls the afterRefresh() method on refresh listeners, and in the case of RefreshFieldHasValueListener it triggered loadFieldInfos() since fieldInfos was null. loadFieldInfos() than called acquireSearcher("field_has_value") before warm-up, failing the assertion. In this change the condition fieldInfos == null is removed from the RefreshFieldHasValueListener.afterRefresh() method in order to avoid calling loadFieldInfos() on a failed refresh. It should be ok since getFieldInfos() already handles lazy loading when fieldInfos is null. I also think we should relax the assertion in assertSearcherIsWarmedUp() to allow FIELD_HAS_VALUE_SOURCE, so that if something like the Field Capabilities API calls loadFieldInfos()/getFieldInfos() before warm-up the assertion won't fail. I would expect that accessing FieldInfos is safe before warm-up, similar to segment stats/infos. Relates elastic#118733 Note: the assertion also tripped for that same test soon after it was refactored in elastic#125650, causing the same test to fail on 8.x branch (8.16, then 8.17 at the time) in a different manner documented here that I'll address in a follow up. Also unmute elastic#114824
…ndomIOExceptionsIT.testRandomDirectoryIOExceptions (#146240) (#146344) Backport of #146240 for 9.3 assertSearcherIsWarmedUp() asserts that the external reader has been warmed up before being accessed for searches, except for specific cases like gatherings segments stats or segments infos in which accessing a non-warmed up external reader are allowed. This assertion started to trip more frequently two weeks ago in the SearchWithRandomIOExceptionsIT testRandomDirectoryIOExceptions, causing the test to be muted on the main branch. The assertion fails when a random IO exception is thrown on purpose by the test during a refresh. Then the ExternalReaderManager is not warmed up and its isWarmedUp flag remains false. But Lucene's ReferenceManager always calls the afterRefresh() method on refresh listeners, and in the case of RefreshFieldHasValueListener it triggered loadFieldInfos() since fieldInfos was null. loadFieldInfos() than called acquireSearcher("field_has_value") before warm-up, failing the assertion. In this change the condition fieldInfos == null is removed from the RefreshFieldHasValueListener.afterRefresh() method in order to avoid calling loadFieldInfos() on a failed refresh. It should be ok since getFieldInfos() already handles lazy loading when fieldInfos is null. I also think we should relax the assertion in assertSearcherIsWarmedUp() to allow FIELD_HAS_VALUE_SOURCE, so that if something like the Field Capabilities API calls loadFieldInfos()/getFieldInfos() before warm-up the assertion won't fail. I would expect that accessing FieldInfos is safe before warm-up, similar to segment stats/infos. Relates #118733 Note: the assertion also tripped for that same test soon after it was refactored in #125650, causing the same test to fail on 8.x branch (8.16, then 8.17 at the time) in a different manner documented here that I'll address in a follow up. Also unmute #114824
…ndomIOExceptionsIT.testRandomDirectoryIOExceptions (#146240) (#146343) Backport of #146240 for 9.4 assertSearcherIsWarmedUp() asserts that the external reader has been warmed up before being accessed for searches, except for specific cases like gatherings segments stats or segments infos in which accessing a non-warmed up external reader are allowed. This assertion started to trip more frequently two weeks ago in the SearchWithRandomIOExceptionsIT testRandomDirectoryIOExceptions, causing the test to be muted on the main branch. The assertion fails when a random IO exception is thrown on purpose by the test during a refresh. Then the ExternalReaderManager is not warmed up and its isWarmedUp flag remains false. But Lucene's ReferenceManager always calls the afterRefresh() method on refresh listeners, and in the case of RefreshFieldHasValueListener it triggered loadFieldInfos() since fieldInfos was null. loadFieldInfos() than called acquireSearcher("field_has_value") before warm-up, failing the assertion. In this change the condition fieldInfos == null is removed from the RefreshFieldHasValueListener.afterRefresh() method in order to avoid calling loadFieldInfos() on a failed refresh. It should be ok since getFieldInfos() already handles lazy loading when fieldInfos is null. I also think we should relax the assertion in assertSearcherIsWarmedUp() to allow FIELD_HAS_VALUE_SOURCE, so that if something like the Field Capabilities API calls loadFieldInfos()/getFieldInfos() before warm-up the assertion won't fail. I would expect that accessing FieldInfos is safe before warm-up, similar to segment stats/infos. Relates #118733 Note: the assertion also tripped for that same test soon after it was refactored in #125650, causing the same test to fail on 8.x branch (8.16, then 8.17 at the time) in a different manner documented here that I'll address in a follow up.
Load field caps from store if they haven't been initialised through a refresh yet.
Keep the plain reads to not mess with performance characteristics too much on the good path but protect against confusing races when loading field infos now (that probably should have been ordered stores in the first place but this was safe due to other locks/volatiles on the refresh path).
Closes #125483