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

Fix file reading in ccr restore service #38117

Merged
merged 5 commits into from
Feb 1, 2019

Conversation

Tim-Brooks
Copy link
Contributor

Currently we use the raw byte array length when calling the IndexInput
read call to determine how many bytes we want to read. However, due to
how BigArrays works, the array length might be longer than the reference
length. This commit fixes the issue and uses the BytesRef length when
calling read. Additionally, it expands the index follow test to index
many more documents. These documents should potentially lead to large
enough segment files to trigger scenarios where this fix matters.

Currently we use the raw byte array length when calling the IndexInput
read call to determine how many bytes we want to read. However, due to
how BigArrays works, the array length might be longer than the reference
length. This commit fixes the issue and uses the BytesRef length when
calling read. Additionally, it expands the index follow test to index
many more documents. These documents should potentially lead to large
enough segment files to trigger scenarios where this fix matters.
@Tim-Brooks Tim-Brooks added >bug v7.0.0 :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features v6.7.0 labels Jan 31, 2019
@Tim-Brooks Tim-Brooks requested a review from ywelsch January 31, 2019 19:12
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@Tim-Brooks Tim-Brooks requested a review from dnhatn January 31, 2019 19:12
@Tim-Brooks
Copy link
Contributor Author

@dnhatn has told me that the assertTotalNumberOfOptimizedIndexing assertion is no longer needed as it is tested in a different place. This assertion was causing issues as I attempt to increased the number of documents indexed (bootstrap recovered documents are not "optimized").

No tests were failing prior to this fix because non of the segment files were big enough to trigger BigArrays to use arrays composed of multiple arrays. Indexing 800-1200 documents does create segment files big enough to cause failures prior to this fix.

@Tim-Brooks Tim-Brooks requested a review from martijnvg January 31, 2019 19:39
Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -101,9 +102,24 @@ public void testFollowIndex() throws Exception {
assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON));
ensureLeaderYellow("index1");

final int firstBatchNumDocs = randomIntBetween(2, 64);
final int firstBatchNumDocs = randomIntBetween(800, 1200);
Copy link
Contributor

Choose a reason for hiding this comment

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

how long does it take to index this? Perhaps we can only do this rarely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The total test takes 1-2 seconds to run with 800-1200 documents. But rarely seems fine since we just want this to fail every once in a while if there was a problem.

I changed this to:

        // Sometimes we want to index a lot of documents to ensure that the recovery works with larger files
        if (rarely()) {
            firstBatchNumDocs = randomIntBetween(1800, 2000);
        } else {
            firstBatchNumDocs = randomIntBetween(10, 64);
        }

@Tim-Brooks Tim-Brooks merged commit 291c4e7 into elastic:master Feb 1, 2019
Tim-Brooks added a commit to Tim-Brooks/elasticsearch that referenced this pull request Feb 1, 2019
Currently we use the raw byte array length when calling the IndexInput
read call to determine how many bytes we want to read. However, due to
how BigArrays works, the array length might be longer than the reference
length. This commit fixes the issue and uses the BytesRef length when
calling read. Additionally, it expands the index follow test to index
many more documents. These documents should potentially lead to large
enough segment files to trigger scenarios where this fix matters.
Tim-Brooks added a commit that referenced this pull request Feb 1, 2019
Currently we use the raw byte array length when calling the IndexInput
read call to determine how many bytes we want to read. However, due to
how BigArrays works, the array length might be longer than the reference
length. This commit fixes the issue and uses the BytesRef length when
calling read. Additionally, it expands the index follow test to index
many more documents. These documents should potentially lead to large
enough segment files to trigger scenarios where this fix matters.
@Tim-Brooks Tim-Brooks deleted the fix_reader branch December 18, 2019 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants