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

Delete Operations on Replicas when Segment Replication is enabled #2804

Closed
wants to merge 7 commits into from
Closed

Delete Operations on Replicas when Segment Replication is enabled #2804

wants to merge 7 commits into from

Conversation

Rishikesh1159
Copy link
Member

Description

This PR fixes delete operations to only write to xlog on replicas. Integration Test for this is also added

Issues Resolved

#2330

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 a review from a team as a code owner April 6, 2022 23:59
@Rishikesh1159 Rishikesh1159 requested a review from mch2 April 7, 2022 00:00
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure d7cb9f2
Log 4268

Reports 4268

@@ -718,7 +704,7 @@ private ExternalReaderManager createReaderManager(RefreshWarmerListener external
private DirectoryReader getDirectoryReader() throws IOException {
// for segment replication: replicas should create the reader from store, we don't want an open IW on replicas.
Copy link
Member

Choose a reason for hiding this comment

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

Lets update this comment with a bit more on why we need to wrap our reader with a SoftDeletesDirectoryReaderWrapper.

@@ -718,7 +704,7 @@ private ExternalReaderManager createReaderManager(RefreshWarmerListener external
private DirectoryReader getDirectoryReader() throws IOException {
// for segment replication: replicas should create the reader from store, we don't want an open IW on replicas.
if (engineConfig.isReadOnly()) {
return DirectoryReader.open(store.directory());
return new SoftDeletesDirectoryReaderWrapper(DirectoryReader.open(store.directory()), Lucene.SOFT_DELETES_FIELD);
}
return DirectoryReader.open(indexWriter);
Copy link
Member

Choose a reason for hiding this comment

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

do we not need writeAllDeletes set to true here? DirectoryReader.open(indexWriter, true, true);

@@ -95,10 +92,18 @@ protected OpenSearchDirectoryReader refreshIfNeeded(OpenSearchDirectoryReader re
// If not using NRT repl.
if (currentInfos == null) {
reader = (OpenSearchDirectoryReader) DirectoryReader.openIfChanged(referenceToRefresh);
if (reader != null) {
logger.info("Num docs primary {}", reader.getDelegate().numDocs());
Copy link
Member

Choose a reason for hiding this comment

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

these logger.infos look left over from testing?

@@ -2286,6 +2295,9 @@ public SegmentInfos getLatestSegmentInfos() {
OpenSearchDirectoryReader reader = null;
try {
reader = externalReaderManager.internalReaderManager.acquire();
if (engineConfig.isReadOnly()) {
return ((StandardDirectoryReader)((SoftDeletesDirectoryReaderWrapper) reader.getDelegate()).getDelegate()).getSegmentInfos();
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a comment here that this is safe because we always wrap the Standard reader with a SoftDeletesDirectoryReaderWrapper for replicas when segrep is on. This will be more clear once we have a separate engine class.

@@ -229,4 +229,45 @@ public void onFailure(Exception e) {
}
});
}

public void testDelOps()throws Exception{
Copy link
Member

Choose a reason for hiding this comment

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

nit - no need to abbreviate. testDeleteOperations.

Rishikesh1159 and others added 7 commits April 11, 2022 13:42
Signed-off-by: Rishikesh1159 <[email protected]>
* Fix Segment replication integ tests by using a single BackgroundIndexer.

BackgroundIndexers begin indexing docs with a docId of 0 up to the requested numDocs.  Using two overlapped the docIds so counts were incorrect.
This changes our tests to use a single indexer, it also improves assertions on segment data on both shards.

Signed-off-by: Marc Handalian <[email protected]>

* Fix Index shards to correctly compare checkpoint version instead of segment gen when determining
if a received checkpoint should be processed. Without this change replicas will ignore checkpoints for merges.

Signed-off-by: Marc Handalian <[email protected]>

* Updated based on PR feedback.

Rename latestUnprocessedCheckpoint to latestReceivedCheckpoint.
Remove redundant checkpoint variable in onNewCheckpoint.
Rename isValidCheckpoint to shouldProcessCheckpoint.
Add missing isAheadOf check to shouldProcessCheckpoint.
Update SegmentReplicationIT's assertSegmentStats to be more readable.
Removed latest seqNo hack.

Signed-off-by: Marc Handalian <[email protected]>
Signed-off-by: Rishikesh1159 <[email protected]>
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure b0146ca
Log 4345

Reports 4345

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure bdc071d
Log 4346

Reports 4346

This pull request was closed.
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.

3 participants