-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Added _shards
header to all write responses.
#7994
Added _shards
header to all write responses.
#7994
Conversation
* `successful`- Indicates the number of shard copies to index operation succeeded on. | ||
* `pending` - Indicates to how many shard copies this index operation still needs to go to at the time index operation | ||
succeeded on the primary shard. This field is only returned if `async` replication is used. | ||
* `failures` - An array that contains replication related errors in the case an index operation failed on a replica shard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need failed
: INT , just like in search.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 I'll add that.
f728490
to
9af8a87
Compare
@javanna @bleskes I updated the PR and the provided feedback has been applied. The other most noticeable change is that the replication logic in TransportShardReplicationOperationAction has been changed to keep better track of the state of replication while it is being performed. This helped to simplify the replication logic. |
@@ -16,6 +16,10 @@ The result of the above delete operation is: | |||
[source,js] | |||
-------------------------------------------------- | |||
{ | |||
"_shards" : { | |||
"total" : 10, | |||
"successful" : 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to the code, I'll add it to the examples as well!
// The failure doesn't include the node id, maybe add it to ShardOperationFailedException... | ||
ShardOperationFailedException sf = shardActionResult.shardFailure; | ||
|
||
ShardIterator thisShardIterator = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not capture the shard info during the failure handling? Then we don't need to search for the iterator..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, let me change that.
Thx @martijnvg .
yeah, I see what you mean. I was thinking wrapping the primary failure with a new exception which has the right info in the message? (ala "Failed to execute on shard [](primary + [] replicas): [MESSAGE]") left some other minor comments. |
Thanks for the feedback @bleskes. I updated the PR. Since we don't have exceptions (the Failure class has no failure wrapping) for the replica shards, I instead just wrap the original primary shard failure on the message of the replica shard failure. I think this is sufficient? |
c99bb0f
to
f6ecd57
Compare
@bleskes @javanna I applied the feedback and Boaz's commits (bleskes@a9b659d and bleskes@6180417), rebased to master and squashed everything to a single commit for clarity purposes. I think this is getting close to get merged now, would be great if someone else can take a look at the PR before it gets merged in. |
|
||
private void assertSyncShardInfo(ActionWriteResponse.ShardInfo shardInfo, NumShards numShards) { | ||
assertThat(shardInfo.getTotal(), equalTo(numShards.totalNumShards)); | ||
assertThat(shardInfo.getSuccessful(), greaterThanOrEqualTo(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not greaterThanOrEqualTo(numShards.numPrimaries)
or even `equalTo(numShards.totalNumShards)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this wasn't using numShards.numPrimaries
, let me change that!
I left a couple of small comments. In general looks good to me. |
@imotov I updated the PR and applied your comments. |
LGTM |
_shards
header to all write responses._shards
header to all write responses.
9f21553
to
6fc0992
Compare
6fc0992
to
33f4241
Compare
33f4241
to
1951ba3
Compare
1951ba3
to
9f10744
Compare
The header indicates to how many shard copies (primary and replicas shards) a write was supposed to go to, to how many shard copies to write succeeded and potentially captures shard failures if writing into a replica shard fails. For async writes it also includes the number of shards a write is still pending. Closes elastic#7994
9f10744
to
ca4f27f
Compare
_shards
header to all write responses._shards
header to all write responses.
The header indicates to how many shard copies (primary and replicas shards) a write was supposed to go to, to how many shard copies to write succeeded and potentially captures shard failures if writing into a replica shard fails.
For async writes it also includes the number of shards a write is still pending.