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

[CCR] Add create and follow api #30602

Merged
merged 13 commits into from
May 26, 2018
Merged

Conversation

martijnvg
Copy link
Member

This PR adds a new api that creates the follow index and starts the follow changes from leader index into the newly created follow index. The api looks the same as the existing follow index api, with the big difference that it creates the follow index.

The create and follow api, creates a follow index based on the IndexMetaData of the leader index, then waits for the shards to become available and the delegate to the existing follow index api.

Relates to #30102

@martijnvg martijnvg added review :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features labels May 15, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@martijnvg martijnvg requested a review from jasontedor May 15, 2018 06:48
* es/ccr: (37 commits)
  Default to one shard (elastic#30539)
  Unmute IndexUpgradeIT tests
  Forbid expensive query parts in ranking evaluation (elastic#30151)
  Docs: Update HighLevelRestClient migration docs (elastic#30544)
  Clients: Switch to new performRequest (elastic#30543)
  [TEST] Fix typo in MovAvgIT test
  Add missing dependencies on testClasses (elastic#30527)
  [TEST] Mute ML test that needs updating to following ml-cpp changes
  Document woes between auto-expand-replicas and allocation filtering (elastic#30531)
  Moved tokenizers to analysis common module (elastic#30538)
  Adjust copy settings versions
  Mute ShrinkIndexIT suite
  SQL: SYS TABLES ordered according to *DBC specs (elastic#30530)
  Deprecate not copy settings and explicitly disallow (elastic#30404)
  [ML] Improve state persistence log message
  Build: Add mavenPlugin cluster configuration method (elastic#30541)
  Re-enable FlushIT tests
  Bump Gradle heap to 2 GB (elastic#30535)
  SQL: Use request flavored methods in tests (elastic#30345)
  Suppress hdfsFixture if there are spaces in the path (elastic#30302)
  ...
* es/ccr: (75 commits)
  Preserve REST client auth despite 401 response (elastic#30558)
  [test] packaging: add windows boxes (elastic#30402)
  Make xpack modules instead of a meta plugin (elastic#30589)
  Mute ShrinkIndexIT
  [ML] DeleteExpiredDataAction should use client with origin (elastic#30646)
  Reindex: Fixed typo in assertion failure message (elastic#30619)
  [DOCS] Fixes list of unconverted snippets in build.gradle
  [DOCS] Reorganizes RBAC documentation
  SQL: Remove dependency for server's version from JDBC driver (elastic#30631)
  Test: increase search logging for LicensingTests
  Adjust serialization version in IndicesOptions
  [TEST] Fix compilation
  Remove version argument in RangeFieldType (elastic#30411)
  Remove unused DirectoryUtils class. (elastic#30582)
  Mitigate date histogram slowdowns with non-fixed timezones. (elastic#30534)
  Add a MovingFunction pipeline aggregation, deprecate MovingAvg agg (elastic#29594)
  Removes AwaitsFix on IndicesOptionsTests
  Template upgrades should happen in a system context (elastic#30621)
  Fix bug in BucketMetrics path traversal (elastic#30632)
  Fixes IndiceOptionsTests to serialise correctly (elastic#30644)
  ...
Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

Looks great; I left a few comments. I will hold off approving as I have a couple of questions.

@@ -2,7 +2,7 @@ ccruser:
cluster:
- manage_ccr
indices:
- names: [ 'index1' ]
- names: [ 'index1', 'index3' ]
Copy link
Member

Choose a reason for hiding this comment

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

I think more meaningful names are in order here? When I look at this and look at FollowIndexSecurityIT it takes some mental energy to keep track of what and where index[1234] are.

logger.info("Running against leader cluster");
Settings indexSettings = Settings.builder()
.put("index.soft_deletes.enabled", true)
.build();
Copy link
Member

Choose a reason for hiding this comment

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

I think this will all fit onto one line.

public void testCreateAndFollowIndex() throws Exception {
final int numDocs = 16;
final String indexName1 = "index3";
final String indexName2 = "index4";
Copy link
Member

Choose a reason for hiding this comment

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

See my comment above about the index names; this is especially onerous with the variable names not being lined up with the concrete index names (e.g., indexName1 is lined up with index3).

@@ -111,6 +111,53 @@ public void testFollowIndex() throws Exception {
}
}

public void testCreateAndFollowIndex() 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.

I do think that two separate tests would be better. One that tests against an index with appropriate permissions, and one that tests against an index without appropriate permissions. Most of the code can be shared between the two methods, it is only about what is asserted at the end that needs to change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, I'm going to change this.


Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(leaderIndexMetaData.getSettings());
// TODO: do we want leader and follow index to have the same UUID?
Copy link
Member

Choose a reason for hiding this comment

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

As you note one line below, we can not do this if the indices are intra-cluster yet I am not sure if I see any advantage to doing this if the indices are inter-cluster.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for checking, I just wanted to point this out during the review. I will remove the todo.

imdBuilder.settings(settingsBuilder);
imdBuilder.index(request.getFollowRequest().getFollowIndex());
for (int shardId = 0 ; shardId < leaderIndexMetaData.getNumberOfShards(); shardId++) {
imdBuilder.putInSyncAllocationIds(shardId, new HashSet<>());
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is strictly needed (it should be the default; see IndexMetaData#build). Did you find otherwise?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I did. Shards of the follow index would never get started (allocation status no_valid_shard_copy).

Copy link
Member

Choose a reason for hiding this comment

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

Okay; this is happening because we copy all of the leader index metadata (which brings along with it the in-sync shard copies on the leader). Then, we have to overwrite with an empty in-sync shard set. I don't think we should do this, I lean towards thinking that we should only copy explicitly what we need from the leader index rather than copying everything and overwriting.

Copy link
Contributor

Choose a reason for hiding this comment

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

I lean towards thinking that we should only copy explicitly what we need from the leader index rather than copying everything and overwriting.

+1 , at least at the current stage where we focus on data and not cluster level metadata (with the exception of mappings).

}
mdBuilder.put(imdBuilder.build(), false);
} else {
mdBuilder.put(leaderIndexMetaData, false);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this case is possible; what am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, this is something that I should have removed.

@@ -338,6 +318,28 @@ public void testFollowNonExistentIndex() throws Exception {
};
}

private void unFollowIndex(String index) 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: unFollow -> unfollow

* es/ccr: (50 commits)
  Reduce CLI scripts to one-liners (elastic#30759)
  SQL: Preserve scoring in bool queries (elastic#30730)
  QA: Switch rolling upgrade to 3 nodes (elastic#30728)
  [TEST] Enable DEBUG logging on testAutoQueueSizingWithMax
  [ML] Don't install empty ML metadata on startup (elastic#30751)
  Add assertion on removing copy_settings (elastic#30748)
  bump lucene version for 6_3_0
  [DOCS] Mark painless execute api as experimental (elastic#30710)
  disable annotation processor for docs (elastic#30610)
  Add more script contexts (elastic#30721)
  Fix default shards count in create index docs (elastic#30747)
  Mute testCorruptFileThenSnapshotAndRestore
  Scripting: Remove getDate methods from ScriptDocValues (elastic#30690)
  Upgrade to Lucene-7.4.0-snapshot-59f2b7aec2 (elastic#30726)
  [Docs] Fix single page :docs:check invocation (elastic#30725)
  Docs: Add uptasticsearch to list of clients (elastic#30738)
  [DOCS] Removes out-dated x-pack/docs/en/index.asciidoc
  [DOCS] Removes redundant index.asciidoc files (elastic#30707)
  [TEST] Reduce forecast overflow to disk test memory limit (elastic#30727)
  Plugins: Remove meta plugins (elastic#30670)
  ...
@martijnvg
Copy link
Member Author

@jasontedor I've updated the PR.

@jasontedor
Copy link
Member

@martijnvg I left one more comment. The overall change looks good but we should come to a resolution on how we will handle sourcing index metadata from the leader (copy and overwrite some fields versus only copy what is needed).

@martijnvg
Copy link
Member Author

@jasontedor I've addressed your comment: c1f8106

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

Looks good.

* es/ccr: (55 commits)
  [DOCS] Fixes typos in security settings
  Fix GeoShapeQueryBuilder serialization after backport
  [DOCS] Splits auditing.asciidoc into smaller files
  Reintroduce mandatory http pipelining support (elastic#30820)
  Painless: Types Section Clean Up (elastic#30283)
  Add support for indexed shape routing in geo_shape query (elastic#30760)
  [test] java tests for archive packaging (elastic#30734)
  Revert "Make http pipelining support mandatory (elastic#30695)" (elastic#30813)
  [DOCS] Fix more edit URLs in Stack Overview (elastic#30704)
  Use correct cluster state version for node fault detection (elastic#30810)
  Change serialization version of doc-value fields.
  [DOCS] Fixes broken link for native realm
  [DOCS] Clarified audit.index.client.hosts (elastic#30797)
  [TEST] Don't expect acks when isolating nodes
  Mute CorruptedFileIT in CCR
  Add a `format` option to `docvalue_fields`. (elastic#29639)
  Fixes UpdateSettingsRequestStreamableTests mutate bug
  Mustes {p0=snapshot.get_repository/10_basic/*} YAML test
  Revert "Mutes MachineLearningTests.testNoAttributes_givenSameAndMlEnabled"
  Only allow x-pack metadata if all nodes are ready (elastic#30743)
  ...
@martijnvg
Copy link
Member Author

@elasticmachine test this please

@martijnvg
Copy link
Member Author

@elasticmachine test this please

@martijnvg
Copy link
Member Author

@elasticmachine test this please

2 similar comments
@martijnvg
Copy link
Member Author

@elasticmachine test this please

@martijnvg
Copy link
Member Author

@elasticmachine test this please

@martijnvg martijnvg merged commit e477147 into elastic:ccr May 26, 2018
martijnvg added a commit that referenced this pull request May 26, 2018
Also renamed FollowExisting* internal names to just Follow* and fixed tests
martijnvg added a commit to martijnvg/elasticsearch that referenced this pull request May 28, 2018
Bug was introduced when create and follow api was added in elastic#30602
martijnvg added a commit that referenced this pull request May 31, 2018
Bug was introduced when create and follow api was added in #30602
martijnvg added a commit that referenced this pull request May 31, 2018
Bug was introduced when create and follow api was added in #30602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CCR Issues around the Cross Cluster State Replication features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants