-
Notifications
You must be signed in to change notification settings - Fork 2.6k
SOLR-15119 Add logs and make default splitMethod to be LINK #2265
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
Open
megancarey
wants to merge
6
commits into
apache:master
Choose a base branch
from
megancarey:jira/SOLR-15119
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4278b8a
Added logs and updated default splitMethod to be lINK
e91d3c6
Add test for splitMethods
f3723a0
Address review feedback
d071b40
Fix logging format for Gradle precommit
fcc005b
Addressing review feedback
0e87b02
Merge branch 'master' into jira/SOLR-15119
megancarey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,10 @@ | |
import static org.apache.solr.common.params.CommonAdminParams.ASYNC; | ||
import static org.apache.solr.common.params.CommonAdminParams.NUM_SUB_SHARDS; | ||
|
||
|
||
/** | ||
* Index split request processed by Overseer. Requests from here go to the host of the parent shard, | ||
* and are processed by SplitOp. | ||
*/ | ||
public class SplitShardCmd implements CollApiCmds.CollectionApiCommand { | ||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
private static final int MIN_NUM_SUB_SHARDS = 2; | ||
|
@@ -81,16 +84,35 @@ public void call(ClusterState state, ZkNodeProps message, @SuppressWarnings({"ra | |
split(state, message,(NamedList<Object>) results); | ||
} | ||
|
||
/** | ||
* Shard splits start here and make additional requests to the host of the parent shard. | ||
* | ||
* The sequence of requests is as follows: | ||
* <ul> | ||
* <li>Verify that there is enough disk space to create sub-shards.</li> | ||
* <li>If splitByPrefix is true, make request to get prefix ranges.</li> | ||
* <li>If this split was attempted previously and there are lingering sub-shards, delete them.</li> | ||
* <li>Create sub-shards in CONSTRUCTION state.</li> | ||
* <li>Add an initial replica to each sub-shard.</li> | ||
* <li>Request that parent shard wait for children to become ACTIVE.</li> | ||
* <li>Execute split: either LINK or REWRITE.</li> | ||
* <li>Apply buffered updates to the sub-shards so they are up-to-date with parent.</li> | ||
* <li>Determine node placement for additional replicas (but do not create yet).</li> | ||
* <li>If replicationFactor is more than 1, set shard state for sub-shards to RECOVERY; else mark ACTIVE.</li> | ||
* <li>Create additional replicas of sub-shards.</li> | ||
* </ul> | ||
*/ | ||
@SuppressWarnings({"rawtypes"}) | ||
public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results) throws Exception { | ||
final String asyncId = message.getStr(ASYNC); | ||
|
||
// get split method, or default to LINK if unspecified | ||
boolean waitForFinalState = message.getBool(CommonAdminParams.WAIT_FOR_FINAL_STATE, false); | ||
String methodStr = message.getStr(CommonAdminParams.SPLIT_METHOD, SolrIndexSplitter.SplitMethod.REWRITE.toLower()); | ||
String methodStr = message.getStr(CommonAdminParams.SPLIT_METHOD, SolrIndexSplitter.SplitMethod.LINK.toLower()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be called out in upgrade-notes, I think. |
||
SolrIndexSplitter.SplitMethod splitMethod = SolrIndexSplitter.SplitMethod.get(methodStr); | ||
if (splitMethod == null) { | ||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown value '" + CommonAdminParams.SPLIT_METHOD + | ||
": " + methodStr); | ||
"': " + methodStr); | ||
} | ||
boolean withTiming = message.getBool(CommonParams.TIMING, false); | ||
|
||
|
@@ -115,7 +137,7 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
String splitKey = message.getStr("split.key"); | ||
DocCollection collection = clusterState.getCollection(collectionName); | ||
|
||
|
||
// verify that parent shard is active; if not, throw exception | ||
Slice parentSlice = getParentSlice(clusterState, collectionName, slice, splitKey); | ||
if (parentSlice.getState() != Slice.State.ACTIVE) { | ||
throw new SolrException(SolrException.ErrorCode.INVALID_STATE, "Parent slice is not active: " + | ||
|
@@ -131,6 +153,7 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Interrupted."); | ||
} | ||
|
||
log.debug("Verifying that there is enough space on disk to create sub-shards"); | ||
RTimerTree t; | ||
if (ccc.getCoreContainer().getNodeConfig().getMetricsConfig().isEnabled()) { | ||
t = timings.sub("checkDiskSpace"); | ||
|
@@ -191,8 +214,8 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
@SuppressWarnings("deprecation") | ||
ShardHandler shardHandler = ccc.getShardHandler(); | ||
|
||
|
||
if (message.getBool(CommonAdminParams.SPLIT_BY_PREFIX, false)) { | ||
log.debug("Making request to SplitOp get doc prefix ranges for each sub-shard"); | ||
t = timings.sub("getRanges"); | ||
|
||
ModifiableSolrParams params = new ModifiableSolrParams(); | ||
|
@@ -234,6 +257,8 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
String rangesStr = fillRanges(ccc.getSolrCloudManager(), message, collection, parentSlice, subRanges, subSlices, subShardNames, firstNrtReplica); | ||
t.stop(); | ||
|
||
// if this shard has attempted a split before and failed, there will be lingering INACTIVE sub-shards. | ||
// clean these up before proceeding | ||
boolean oldShardsDeleted = false; | ||
for (String subSlice : subSlices) { | ||
Slice oSlice = collection.getSlice(subSlice); | ||
|
@@ -269,8 +294,8 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
collection = clusterState.getCollection(collectionName); | ||
} | ||
|
||
// create the child sub-shards in CONSTRUCTION state | ||
String nodeName = parentShardLeader.getNodeName(); | ||
|
||
t = timings.sub("createSubSlicesAndLeadersInState"); | ||
for (int i = 0; i < subRanges.size(); i++) { | ||
String subSlice = subSlices.get(i); | ||
|
@@ -322,7 +347,6 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
new AddReplicaCmd(ccc).addReplica(clusterState, new ZkNodeProps(propMap), results, null); | ||
} | ||
|
||
|
||
{ | ||
final ShardRequestTracker syncRequestTracker = CollectionHandlingUtils.syncRequestTracker(ccc); | ||
String msgOnError = "SPLITSHARD failed to create subshard leaders"; | ||
|
@@ -363,6 +387,7 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
, parentShardLeader.getName(), slice, collectionName, parentShardLeader); | ||
} | ||
|
||
// execute actual split | ||
ModifiableSolrParams params = new ModifiableSolrParams(); | ||
params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.SPLIT.toString()); | ||
params.set(CommonAdminParams.SPLIT_METHOD, splitMethod.toLower()); | ||
|
@@ -413,15 +438,6 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
|
||
log.debug("Successfully applied buffered updates on : {}", subShardNames); | ||
|
||
// Replica creation for the new Slices | ||
|
||
Set<String> nodes = clusterState.getLiveNodes(); | ||
List<String> nodeList = new ArrayList<>(nodes.size()); | ||
nodeList.addAll(nodes); | ||
|
||
// Remove the node that hosts the parent shard for replica creation. | ||
nodeList.remove(nodeName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also cleaned this up because it was bugging me :) nodeList is never used. |
||
|
||
// TODO: change this to handle sharding a slice into > 2 sub-shards. | ||
|
||
// we have already created one subReplica for each subShard on the parent node. | ||
|
@@ -550,6 +566,7 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
// this ensures that the logic inside ReplicaMutator to update sub-shard state to 'active' | ||
// always gets a chance to execute. See SOLR-7673 | ||
|
||
// if replicationFactor > 1, set shard state for sub-shards to RECOVERY; otherwise mark ACTIVE | ||
if (repFactor == 1) { | ||
// A commit is needed so that documents are visible when the sub-shard replicas come up | ||
// (Note: This commit used to be after the state switch, but was brought here before the state switch | ||
|
@@ -619,6 +636,10 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList<O | |
if (withTiming) { | ||
results.add(CommonParams.TIMING, timings.asNamedList()); | ||
} | ||
|
||
if (log.isDebugEnabled()) { | ||
log.debug("Timings for split sub-ops: {}", timings.toString()); | ||
} | ||
success = true; | ||
// don't unlock the shard yet - only do this if the final switch-over in | ||
// ReplicaMutator succeeds (or fails) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.