Skip to content

Flaky ElasticsearchIndexTest: a reading of the search statistics can miss a released scroll #5062

Closed

Description

@porunov

ElasticsearchIndexTest.shouldReleaseTheContextWhenTheConsumerStopsBeforeTheEnd fails now and then. Its check that the result was read through a scroll doesn't find the scroll counted:

ElasticsearchIndexTest.shouldReleaseTheContextWhenTheConsumerStopsBeforeTheEnd:1190->assertReadInPages:1301 this result is read through a scroll ==> expected: <true> but was: <false>

It failed in three runs:

Cause: the test can read the statistics in the middle of a release

  • The tests of the search contexts read _nodes/stats/indices/search until open_contexts is back at the number they expect, then check scroll_total in that same reading.
  • Closing the stream releases the scroll context with a request the client doesn't wait for, right before the test's first reading. On OpenSearch and Elasticsearch 6, every paging mode reads this result through a scroll.
  • When a node frees a scroll context, it updates scroll_total and open_contexts one after the other, and it reads them one after the other when it reports them:
    • Elasticsearch 7.17, 8.15 and 9 and OpenSearch 2.19 and 3.9 count the freed scroll first, but read scroll_total first.
    • Elasticsearch 6.6 stops counting the context open first.
  • So a reading that overlaps the release can show the context gone without its scroll. The next reading, a round trip later, has both.

Reproduction: repeat the test's scenario (read the first hit, close the stream, wait for the open contexts) and keep the first reading in which the open contexts are back. It missed the released scroll:

  • in 4 of 300 rounds on OpenSearch 2.19.6;
  • in 2 of 300 on Elasticsearch 9.5.4;
  • in 9 of 300 on Elasticsearch 6.6.0.

The reading after it missed it in none of them.

Proposed fix: the tests take two readings in a row in which the open contexts are back at the expected number, and use the second.

Activity

  1. added this to the 1.2.0 milestone on Oct 12, 2026
  2. added a commit that references this issue on Oct 12, 2026
    efbe8f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions