-
Notifications
You must be signed in to change notification settings - Fork 24.2k
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
Add global checkpoint tracking on the primary #26666
Merged
jasontedor
merged 25 commits into
elastic:master
from
jasontedor:track-global-checkpoints
Sep 18, 2017
+544
−210
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
244c0bd
Add global checkpoint tracking on the primary
jasontedor 8eaade3
Checkstyle
jasontedor 80654ed
Tighter assertions
jasontedor 51c6948
Remove leftover debugging code
jasontedor 41cd84a
Fix comment
jasontedor b8a5183
Cache global checkpoint lookup
jasontedor c402ddf
Cleaner handling of update
jasontedor 37872bf
Share some code
jasontedor 0a104e0
Fix comment
jasontedor d7eb28f
Rename method
jasontedor 4f52100
Make final
jasontedor 7dde7bc
Add assertion message
jasontedor 601300d
Fix
jasontedor bd6b8e7
Fix assertion
jasontedor d15b7b7
Remove imports
jasontedor 17c4d20
Fix assertion
jasontedor 39fcecc
Merge branch 'master' into track-global-checkpoints
jasontedor 89dd3a2
Disable BWC testing
jasontedor bb5603d
Rename field
jasontedor dee5e0f
Add test
jasontedor 375ad63
Fix typo
jasontedor 8276497
Add another test
jasontedor c74599f
hashCode
jasontedor f9a06a3
trace logging
jasontedor 514db2e
Simplify
jasontedor File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -531,7 +531,8 @@ public void onResponse(Releasable releasable) { | |
try { | ||
final ReplicaResult replicaResult = shardOperationOnReplica(request, replica); | ||
releasable.close(); // release shard operation lock before responding to caller | ||
final TransportReplicationAction.ReplicaResponse response = new ReplicaResponse(replica.getLocalCheckpoint()); | ||
final TransportReplicationAction.ReplicaResponse response = | ||
new ReplicaResponse(replica.getLocalCheckpoint(), replica.getGlobalCheckpoint()); | ||
replicaResult.respond(new ResponseListener(response)); | ||
} catch (final Exception e) { | ||
Releasables.closeWhileHandlingException(releasable); // release shard operation lock before responding to caller | ||
|
@@ -1006,6 +1007,11 @@ public void updateLocalCheckpointForShard(String allocationId, long checkpoint) | |
indexShard.updateLocalCheckpointForShard(allocationId, checkpoint); | ||
} | ||
|
||
@Override | ||
public void updateGlobalCheckpointForShard(final String allocationId, final long globalCheckpoint) { | ||
indexShard.updateGlobalCheckpointForShard(allocationId, globalCheckpoint); | ||
} | ||
|
||
@Override | ||
public long localCheckpoint() { | ||
return indexShard.getLocalCheckpoint(); | ||
|
@@ -1025,47 +1031,60 @@ public ReplicationGroup getReplicationGroup() { | |
|
||
public static class ReplicaResponse extends ActionResponse implements ReplicationOperation.ReplicaResponse { | ||
private long localCheckpoint; | ||
private long globalCheckpoint; | ||
|
||
ReplicaResponse() { | ||
|
||
} | ||
|
||
public ReplicaResponse(long localCheckpoint) { | ||
public ReplicaResponse(long localCheckpoint, long globalCheckpoint) { | ||
/* | ||
* A replica should always know its own local checkpoint so this should always be a valid sequence number or the pre-6.0 local | ||
* A replica should always know its own local checkpoints so this should always be valida sequence number or the pre-6.0 | ||
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. valida? |
||
* checkpoint value when simulating responses to replication actions that pre-6.0 nodes are not aware of (e.g., the global | ||
* checkpoint background sync, and the primary/replica resync). | ||
*/ | ||
assert localCheckpoint != SequenceNumbers.UNASSIGNED_SEQ_NO; | ||
this.localCheckpoint = localCheckpoint; | ||
this.globalCheckpoint = globalCheckpoint; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { | ||
super.readFrom(in); | ||
localCheckpoint = in.readZLong(); | ||
} else { | ||
// 5.x used to read empty responses, which don't really read anything off the stream, so just do nothing. | ||
localCheckpoint = SequenceNumbersService.PRE_60_NODE_LOCAL_CHECKPOINT; | ||
localCheckpoint = SequenceNumbersService.PRE_60_NODE_CHECKPOINT; | ||
} | ||
if (in.getVersion().onOrAfter(Version.V_6_0_0_rc1)) { | ||
globalCheckpoint = in.readZLong(); | ||
} else { | ||
globalCheckpoint = SequenceNumbersService.PRE_60_NODE_CHECKPOINT; | ||
} | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { | ||
super.writeTo(out); | ||
out.writeZLong(localCheckpoint); | ||
} else { | ||
// we use to write empty responses | ||
Empty.INSTANCE.writeTo(out); | ||
} | ||
if (out.getVersion().onOrAfter(Version.V_6_0_0_rc1)) { | ||
out.writeZLong(globalCheckpoint); | ||
} | ||
} | ||
|
||
@Override | ||
public long localCheckpoint() { | ||
return localCheckpoint; | ||
} | ||
|
||
@Override | ||
public long globalCheckpoint() { | ||
return globalCheckpoint; | ||
} | ||
|
||
} | ||
|
||
/** | ||
|
This file contains 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
Oops, something went wrong.
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.
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.
💯