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

Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication #11786

Merged
merged 2 commits into from
Jan 8, 2024

Conversation

dreamer-89
Copy link
Member

@dreamer-89 dreamer-89 commented Jan 6, 2024

Description

This change updates testSegRepSucceedsOnPreviousCopiedFiles shard level test to wait for file copy operations to complete in first round of segment replication before proceeding to next round without which it is possible to have concurrent access on segment files. 1) FIle copy operations from first round 2) File checksum validation from next round.

Issues Resolves

Resolves #10885

Background

With #9630, we introduced optimization to avoid re-downloading files already on disk but not referenced by active reader. With #10725, we made RemoteStoreReplicationSource compliant with ReplicationSource by making download logic asynchronous. I suspect this resulted scenario where file copy remains in-progress from first round of segment replication which breaks checksum validations on next round.

Error trace for failure builds

Caused by: java.io.UncheckedIOException: Error reading name [_0.si], length [325], checksum [r5w8xw], writtenBy [9.8.0]
	at org.opensearch.indices.replication.SegmentReplicationTarget.validateLocalChecksum(SegmentReplicationTarget.java:246) 
...
Caused by: java.nio.file.AccessDeniedException: MockDirectoryWrapper: file "_0.si" is still open for writing
	at org.apache.lucene.tests.store.MockDirectoryWrapper.openInput(MockDirectoryWrapper.java:808) ~[lucene-test-framework-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.apache.lucene.store.FilterDirectory.openInput(FilterDirectory.java:101) ~[lucene-core-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.apache.lucene.store.FilterDirectory.openInput(FilterDirectory.java:101) ~[lucene-core-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.opensearch.indices.replication.SegmentReplicationTarget.validateLocalChecksum(SegmentReplicationTarget.java:236) ~[main/:?]
...
Caused by: java.lang.RuntimeException: unclosed IndexOutput: _0.si
	at org.apache.lucene.tests.store.MockDirectoryWrapper.addFileHandle(MockDirectoryWrapper.java:783) ~[lucene-test-framework-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.apache.lucene.tests.store.MockDirectoryWrapper.createOutput(MockDirectoryWrapper.java:719) ~[lucene-test-framework-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.apache.lucene.store.FilterDirectory.createOutput(FilterDirectory.java:75) ~[lucene-core-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.opensearch.index.store.ByteSizeCachingDirectory.createOutput(ByteSizeCachingDirectory.java:153) ~[main/:?]
        at org.apache.lucene.store.Directory.copyFrom(Directory.java:181) ~[lucene-core-9.8.0.jar:9.8.0 d914b3722bd5b8ef31ccf7e8ddc638a87fd648db - 2023-09-21 21:57:47]
	at org.opensearch.index.store.Store$StoreDirectory.copyFrom(Store.java:978) ~[main/:?]

testSegRepSucceedsOnPreviousCopiedFiles steps

Step 1. Index docs
Step 2. Use custom RemoteStoreReplicationSource where exception is post getSegmentFiles. With background files are been copied, we halted first round of segment replication pre-maturely. Below code shows the custom remote store replication source used during first round of segrep. We throw exception post getsegmentFiles method call.

        return new RemoteStoreReplicationSource(shard) {
            @Override
            public void getCheckpointMetadata(
                long replicationId,
                ReplicationCheckpoint checkpoint,
                ActionListener<CheckpointInfoResponse> listener
            ) {
                super.getCheckpointMetadata(replicationId, checkpoint, listener);
            }

            @Override
            public void getSegmentFiles(
                long replicationId,
                ReplicationCheckpoint checkpoint,
                List<StoreFileMetadata> filesToFetch,
                IndexShard indexShard,
                BiConsumer<String, Long> fileProgressTracker,
                ActionListener<GetSegmentFilesResponse> listener
            ) {
                super.getSegmentFiles(replicationId, checkpoint, filesToFetch, indexShard, (fileName, bytesRecovered) -> {}, listener);
                postGetFilesRunnable.run(); --> This can be invoked while files download is in progress, which fiddles with next round of segment replication validateCheckSum method call.
            }
  1. Validate on-disk store is non-empty (validates previous step).
  2. Perform next round of segment replication and validate on-disk files are considered.
    Issue: At step 2, since download (getSegmentFiles) is async in nature, throwing exception right after getSegmentFiles is not right. We need mechanism that tells files were downloaded completely.

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
  • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
    - [ ] Public documentation issue/PR created

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.

Copy link
Contributor

github-actions bot commented Jan 6, 2024

❌ Gradle check result for 8b69e04: 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?

Copy link
Contributor

github-actions bot commented Jan 6, 2024

Compatibility status:

Checks if related components are compatible with change 95a866a

Incompatible components

Skipped components

Compatible components

Compatible components: [https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/custom-codecs.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/performance-analyzer.git]

…s are reused for replication

Signed-off-by: Suraj Singh <surajrider@gmail.com>
Signed-off-by: Suraj Singh <surajrider@gmail.com>
@dreamer-89 dreamer-89 marked this pull request as ready for review January 8, 2024 18:29
Copy link
Contributor

github-actions bot commented Jan 8, 2024

✅ Gradle check result for 95a866a: SUCCESS

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cbfe160) 71.31% compared to head (95a866a) 71.18%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11786      +/-   ##
============================================
- Coverage     71.31%   71.18%   -0.14%     
+ Complexity    59221    59149      -72     
============================================
  Files          4911     4911              
  Lines        278667   278667              
  Branches      40528    40528              
============================================
- Hits         198735   198363     -372     
- Misses        63375    63776     +401     
+ Partials      16557    16528      -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dreamer-89 dreamer-89 added the backport 2.x Backport to 2.x branch label Jan 8, 2024
@dreamer-89 dreamer-89 merged commit fe98aad into opensearch-project:main Jan 8, 2024
58 of 69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 8, 2024
…s are reused for replication (#11786)

* Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication

Signed-off-by: Suraj Singh <surajrider@gmail.com>

* Fix original shard level unit test

Signed-off-by: Suraj Singh <surajrider@gmail.com>

---------

Signed-off-by: Suraj Singh <surajrider@gmail.com>
(cherry picked from commit fe98aad)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kotwanikunal pushed a commit that referenced this pull request Jan 25, 2024
…s are reused for replication (#11786)

* Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication

Signed-off-by: Suraj Singh <surajrider@gmail.com>

* Fix original shard level unit test

Signed-off-by: Suraj Singh <surajrider@gmail.com>

---------

Signed-off-by: Suraj Singh <surajrider@gmail.com>
(cherry picked from commit fe98aad)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
andrross pushed a commit that referenced this pull request Mar 14, 2024
…s are reused for replication (#11786)

* Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication

Signed-off-by: Suraj Singh <surajrider@gmail.com>

* Fix original shard level unit test

Signed-off-by: Suraj Singh <surajrider@gmail.com>

---------

Signed-off-by: Suraj Singh <surajrider@gmail.com>
(cherry picked from commit fe98aad)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kotwanikunal pushed a commit that referenced this pull request Mar 14, 2024
…s are reused for replication (#11786) (#11806)

* Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication



* Fix original shard level unit test



---------


(cherry picked from commit fe98aad)

Signed-off-by: Suraj Singh <surajrider@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
rayshrey pushed a commit to rayshrey/OpenSearch that referenced this pull request Mar 18, 2024
…s are reused for replication (opensearch-project#11786)

* Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication

Signed-off-by: Suraj Singh <surajrider@gmail.com>

* Fix original shard level unit test

Signed-off-by: Suraj Singh <surajrider@gmail.com>

---------

Signed-off-by: Suraj Singh <surajrider@gmail.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…s are reused for replication (opensearch-project#11786)

* Use SegmentReplicationTarget test to validate non-active on-disk files are reused for replication

Signed-off-by: Suraj Singh <surajrider@gmail.com>

* Fix original shard level unit test

Signed-off-by: Suraj Singh <surajrider@gmail.com>

---------

Signed-off-by: Suraj Singh <surajrider@gmail.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch bug Something isn't working flaky-test Random test failure that succeeds on second run skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] RemoteIndexShardTests.testSegRepSucceedsOnPreviousCopiedFiles is flaky - suite timeout was reached
2 participants