Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Index Operations to Translog from Engine #2977

Closed
wants to merge 4 commits into from
Closed

Add Index Operations to Translog from Engine #2977

wants to merge 4 commits into from

Conversation

Rishikesh1159
Copy link
Member

@Rishikesh1159 Rishikesh1159 commented Apr 19, 2022

Description

This PR will allow us to decouple adding Index operations to Lucene and adding Index operations to Translog. This would be useful for segment replication, as we will need to just add Index operation to replicas translog instead of performing full index operation. We will only use this method when segment replication is enabled and when we are on a replica node. The logic for checking if segment replication is enabled and is replica node will be added later in a different PR.

This is a part of the process of merging our feature branch - feature/segment-replication - back into main by re-PRing our changes from the feature branch.
The breakdown of the plan to merge to main is detailed here: #2926
For added context on segment replication - here's the design proposal #2229

Issues Resolved

#2926

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@Rishikesh1159 Rishikesh1159 requested review from a team and reta as code owners April 19, 2022 16:23
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure bbca4fb
Log 4620

Reports 4620

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 4b29ffa
Log 4622

Reports 4622

@kartg
Copy link
Member

kartg commented Apr 19, 2022

Looks good to me! 🚀 My one nitpick/request would be to add javadocs to the new API in Engine

I'm stopping short of an approval since I'd like a fresh set of eyes on this 😄

@Rishikesh1159
Copy link
Member Author

Looks good to me! 🚀 My one nitpick/request would be to add javadocs to the new API in Engine

I'm stopping short of an approval since I'd like a fresh set of eyes on this 😄

Sure. I will update the new API with java docs

@@ -1075,6 +1059,44 @@ public IndexResult index(Index index) throws IOException {
}
}

@Override
public Engine.IndexResult addIndexOperationToTranslog(Index index) throws IOException {
try (Releasable ignored = versionMap.acquireLock(index.uid().bytes())) {
Copy link
Collaborator

@reta reta Apr 19, 2022

Choose a reason for hiding this comment

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

I believe you need to acquire readLock lock here (as all other public methods do):

try (ReleasableLock ignored = readLock.acquire()) {
 ....
}

Also, it probably makes sense to do basic checks like ensureOpen(); and assertIncomingSequenceNumber before adding anything to translog.

ensureOpen();
assert assertIncomingSequenceNumber(index.origin(), index.seqNo());

Another concern I have is that write operations like index and delete do update lastWriteNanos but this is not done here, is there a reason?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd actually prefer to leave this method out until a segrep PR needs it. Nothing in this PR, except tests, call this method so it doesn't make sense to add at this point until we have a change that's actually using it. That will also concretely communicate why the method is needed to those not intimately working segrep; along with how to best structure the method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 no objections, certainly

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

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

I like the forward thinking approach but lets only introduce methods actually being used at this point and hold on those that are needed in a future PR.

@@ -1075,6 +1059,44 @@ public IndexResult index(Index index) throws IOException {
}
}

@Override
public Engine.IndexResult addIndexOperationToTranslog(Index index) throws IOException {
try (Releasable ignored = versionMap.acquireLock(index.uid().bytes())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd actually prefer to leave this method out until a segrep PR needs it. Nothing in this PR, except tests, call this method so it doesn't make sense to add at this point until we have a change that's actually using it. That will also concretely communicate why the method is needed to those not intimately working segrep; along with how to best structure the method.

@kartg
Copy link
Member

kartg commented Apr 19, 2022

I like the forward thinking approach but lets only introduce methods actually being used at this point and hold on those that are needed in a future PR.

The aim of these PRs was to front-load refactoring in existing classes that we've made in the feature/segment-replication feature branch. This way, upcoming PRs on segment replication can focus on functional changes instead of bundling in changes to underlying classes.

If we leave out the addIndexOperationToTranslog API in Engine, then this PR boils down to simply extracting the addIndexOperationToTranslog(Index index, IndexResult indexResult) private method, which doesn't add value in isolation 😅 Thus, exposing an API but not wiring up any callers was our attempt to split the difference.

@nknize any suggestions on how we could balance this better?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 61649a9
Log 4625

Reports 4625

@nknize
Copy link
Collaborator

nknize commented Apr 20, 2022

any suggestions on how we could balance this better?

We should merge #2904 behind a feature flag (e.g., opensearch.segment_replication_feature_flag_enabled) and then work on merging segrep to main so we can do away with the feature branch and continue feature development on main. Main is meant to be the (unstable) working branch that is constantly moving so I'm not concerned about half baked features so long as they're feature flagged.

@kotwanikunal
Copy link
Member

kotwanikunal commented Jun 14, 2022

@Rishikesh1159 Any updates on this? Are you still blocked?

@Rishikesh1159
Copy link
Member Author

Closing this PR. Changes necessary are added in a different PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants