Skip to content

Conversation

arteam
Copy link
Contributor

@arteam arteam commented Sep 4, 2024

After finishing an integration test, we run some checks against the test cluster, among others we assert there are no leaky acquired index commits left in InternalTestCluster#beforeIndexDeletion. The issue is that while we check the test cluster before we shut it down, we can't guarantee that there wouldn't be a new commit triggered by a background merge which will acquire an index commit. But we actually don't care about these commits acquired internally as part of CombinedDeletionPolicy#commitsListener callbacks. We just want to make sure that all index commits that have been acquired explicitly are also released. So, we make an explicit distinction between external and internal index commits that are tracked in CombinedDeletionPolicy.

ES-8407

@arteam arteam force-pushed the track-index-commits-acquired-by-commits-listener branch from b681d48 to 7d588c7 Compare September 4, 2024 10:54
@arteam arteam added the :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. label Sep 4, 2024
@arteam arteam marked this pull request as ready for review September 4, 2024 13:15
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Sep 4, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@arteam arteam changed the title Track index commits internally acquired by the commits listener in CombinedDeletionPolicy [test] Track index commits internally acquired by the commits listener in CombinedDeletionPolicy Sep 4, 2024
@arteam arteam added the >test Issues or PRs that are addressing/adding tests label Sep 4, 2024
@arteam arteam marked this pull request as draft September 4, 2024 13:18
Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me though it is slightly controversial.

@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Sep 4, 2024
@arteam arteam marked this pull request as ready for review September 5, 2024 07:19
Copy link
Contributor

@fcofdez fcofdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep the acquiredIndexCommits map as it's today but maybe add an extra Set<IndexCommit> listenerAcquiredCommits or something like that that only gets populated with the commits acquired for the listener and we could simply remove them from that new set whenever the refCount reaches 0 in releaseCommit. That feels more correct to me.

@fcofdez
Copy link
Contributor

fcofdez commented Sep 6, 2024

In fact that was your original approach @arteam :D

@arteam
Copy link
Contributor Author

arteam commented Sep 6, 2024

@fcofdez Yes, it was! I'm happy to proceed with either approach. I'm going to wait for an additional opinion from @henningandersen or @ywangd .

Copy link
Contributor

@kingherc kingherc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I also like @fcofdez 's comment on leaving acquiredIndexCommits as it was (with both internally/externally acquired commits), thus reducing risk for bugs in that crucial part of the code, and having a separate Set for externally acquired commits that will just be used for our test assertions (meaning any bug in the new code will only affect tests). Not saying there's a bug, but just feels safer.

@arteam arteam requested review from fcofdez and kingherc September 8, 2024 23:55
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a question.

Personally I'd prefer to keep the production code changes as minimal as possible. So a separate set for tracking works better for me. I'd also suggest we wrap relevant logic with Assertions.ENABLED check when applicable.

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and I am ok with reverting to the previous direction based on majority vote 🙂 .

@arteam
Copy link
Contributor Author

arteam commented Sep 9, 2024

@elasticmachine update branch

@arteam arteam requested review from fcofdez, henningandersen, kingherc and ywangd and removed request for fcofdez and kingherc September 9, 2024 18:09
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

arteam and others added 5 commits September 10, 2024 09:01
…letionPolicy.java

Co-authored-by: Yang Wang <ywangd@gmail.com>
…letionPolicy.java

Co-authored-by: Yang Wang <ywangd@gmail.com>
…letionPolicy.java

Co-authored-by: Yang Wang <ywangd@gmail.com>
@arteam arteam requested review from fcofdez and removed request for fcofdez September 10, 2024 08:08
@arteam
Copy link
Contributor Author

arteam commented Sep 10, 2024

@elasticmachine update branch

@arteam arteam added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Sep 10, 2024
@elasticsearchmachine elasticsearchmachine merged commit 8c088d5 into elastic:main Sep 10, 2024
16 checks passed
@arteam arteam deleted the track-index-commits-acquired-by-commits-listener branch September 10, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. >non-issue serverless-linked Added by automation, don't add manually Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. >test Issues or PRs that are addressing/adding tests v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants