Skip to content

Commit

Permalink
Adding comments and removing log statements
Browse files Browse the repository at this point in the history
Signed-off-by: Rishikesh1159 <[email protected]>
  • Loading branch information
Rishikesh1159 committed Apr 11, 2022
1 parent df7a777 commit bdc071d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void onFailure(Exception e) {
});
}

public void testDelOps()throws Exception{
public void testDeleteOperations()throws Exception{
final String nodeA = internalCluster().startNode();
final String nodeB = internalCluster().startNode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,12 @@ 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.
// for segment replication: replicas should create the reader from store and, we don't want an open IW on replicas.
// We should always wrap replicas with a SoftDeletesDirectoryReaderWrapper as we use soft deletes when segment replication is on for deletions
if (engineConfig.isReadOnly()) {
return new SoftDeletesDirectoryReaderWrapper(DirectoryReader.open(store.directory()), Lucene.SOFT_DELETES_FIELD);
}
return DirectoryReader.open(indexWriter);
return DirectoryReader.open(indexWriter, true, true);
}

@Override
Expand Down Expand Up @@ -2295,6 +2296,7 @@ public SegmentInfos getLatestSegmentInfos() {
OpenSearchDirectoryReader reader = null;
try {
reader = externalReaderManager.internalReaderManager.acquire();
// This is safe, as we always wrap Standard reader with a SoftDeletesDirectoryReaderWrapper for replicas when segment replication is enabled
if (engineConfig.isReadOnly()) {
return ((StandardDirectoryReader)((SoftDeletesDirectoryReaderWrapper) reader.getDelegate()).getDelegate()).getSegmentInfos();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,11 @@ 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());
}
} else {
// Open a new reader, sharing any common segment readers with the old one:
DirectoryReader innerReader = StandardDirectoryReader.open(referenceToRefresh.directory(), currentInfos, subs, null);
final DirectoryReader softDeletesDirectoryReaderWrapper = new SoftDeletesDirectoryReaderWrapper(innerReader, Lucene.SOFT_DELETES_FIELD);
logger.info("Doc count {}", softDeletesDirectoryReaderWrapper.numDocs());
logger.info("Deleted doc count {}", softDeletesDirectoryReaderWrapper.numDeletedDocs());
reader = OpenSearchDirectoryReader.wrap(softDeletesDirectoryReaderWrapper, referenceToRefresh.shardId());
logger.info("reader Doc count {}", reader.numDocs());
logger.info("reader Deleted doc count {}", reader.numDeletedDocs());
logger.trace("updated to SegmentInfosVersion=" + currentInfos.getVersion() + " reader=" + innerReader);
}
return reader;
Expand Down

0 comments on commit bdc071d

Please sign in to comment.