Skip to content

Conversation

@ask-kamal-nayan
Copy link

@ask-kamal-nayan ask-kamal-nayan commented Jan 20, 2026

Description

This PR fixes failing IndexShardTests by addressing two main issues:

  1. Adding explicit null-checking when accessing the underlying Engine reference
  2. Fixing FileMetadata serialization/deserialization for proper handling of Lucene file names in non-optimized indices

Problem 1: Engine Null Reference

Several IndexShardTests were failing with NullPointerException when tests accessed shard methods before the engine was fully initialized or after it was closed.

Problem 2: FileMetadata Serialization

For non-optimized (standard Lucene) indices, file names were incorrectly being used in serialized format (e.g., segment_1.si:::lucene) instead of plain file names (e.g., segment_1.si), causing file lookup failures and test issues.

Problem 3: RemoteStoreRefreshListenerTests Failing:

Because of the changes made to RemoteStoreRefreshListener class to support mulit-format because of which all tests in RemoteStoreRefreshListenerTests were failing.

Tests Now Passing (4 tests fixed)

  1. testCloseShardWhileEngineIsWarming
  2. testEstimateTotalDocSize
  3. testIndexingOperationsListeners
  4. testSyncSegmentsFromGivenRemoteSegmentStore

All RemoteStoreRefreshListenerTests are fixed now:

image

Before this fix 81 tests were passing:
image
After this fix 85 tests are passing. Most of the remaining failed tests are related to translogOps compression during shardClose call:
image

Tests:

  • :modules:parquet-data-format:internalClusterTest are passing.
  • ParquetRemoteStoreRecoveryIt tests are passing except testReplicaPromotionWithTranslogReplay, also failing in datafusion branch.
  • Manual tests going on.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

❌ Gradle check result for 0ae6d0b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❌ Gradle check result for 6154c82: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❌ Gradle check result for e1948d5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Collection<FileMetadata> localFileMetadataList = catalogSnapshotRef.getRef().getFileMetadataList();
Set<String> localFiles = localFileMetadataList.stream()
.filter(fm -> !RemoteStoreRefreshListener.EXCLUDE_FILES.contains(fm.file()))
.map(FileMetadata::serialize)
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are local file references, why are we using serialize? We should be using FileMetadata::file here.

Copy link
Author

Choose a reason for hiding this comment

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

There is a check below which checks if the uploadedFiles contains these local files and uploadedFile names are serialized. I have updated the name to serializedLocalFiles for better readability of the code.

Comment on lines 5961 to 5968
if(isOptimizedIndex())
{
segmentNFile = file;
}
else
{
segmentNFile = fileMetadata.file();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are doing a new FileMetadata(file) call, file should already be delimited with data format name, why is the segmentsNFile reference okay to be updated as file here?

Copy link
Author

Choose a reason for hiding this comment

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

These segmentNFiles are used by caller syncSegmentsFromGivenRemoteSegmentStore. syncSegmentsFromGivenRemoteSegmentStore API calls OpenInput on this segmentNFile so for normal storeDirectory we need the name in plain file format but for compositeStoreDirectory we need the serialized name so that it can be routed to correct directory.

@github-actions
Copy link
Contributor

❌ Gradle check result for 13fbfed: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@Override
public void deleteFile(String name) throws IOException {
String remoteFilename = getExistingRemoteFilename(name);
String fileName = new FileMetadata(name).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we use serialize directly here?

Comment on lines 5959 to 5966
assert segmentNFile == null : "There should be only one SegmentInfosSnapshot file";
if(isOptimizedIndex())
{
if(isOptimizedIndex()){
segmentNFile = file;
}
else
{
else{
segmentNFile = fileMetadata.file();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting

@github-actions
Copy link
Contributor

❌ Gradle check result for 007efe5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@bharath-techie bharath-techie merged commit d2f1abe into opensearch-project:feature/datafusion Jan 22, 2026
7 of 31 checks passed
abhita pushed a commit to abhita/OpenSearch that referenced this pull request Jan 26, 2026
… fix FileMetadata serialization handling (opensearch-project#20444)

* Fixing IndexShardTests recovery tests

* Removed unnecessary comment

* updated getNativeBytesused api

* Fixed RemoteStoreListenerTests and resolved comments

* nit fix

---------

Co-authored-by: Kamal Nayan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants