@@ -93,7 +93,10 @@ protected void nodeOperation(AllocatedPersistentTask task, ShardFollowTask param
93
93
this .client .getRemoteClusterClient (params .getLeaderClusterAlias ()) : this .client ;
94
94
logger .info ("Starting shard following [{}]" , params );
95
95
fetchGlobalCheckpoint (client , params .getFollowShardId (),
96
- followGlobalCheckPoint -> prepare (leaderClient , shardFollowNodeTask , params , followGlobalCheckPoint ), task ::markAsFailed );
96
+ followGlobalCheckPoint -> {
97
+ shardFollowNodeTask .updateProcessedGlobalCheckpoint (followGlobalCheckPoint );
98
+ prepare (leaderClient , shardFollowNodeTask , params , followGlobalCheckPoint );
99
+ }, task ::markAsFailed );
97
100
}
98
101
99
102
void prepare (Client leaderClient , ShardFollowNodeTask task , ShardFollowTask params , long followGlobalCheckPoint ) {
@@ -107,10 +110,13 @@ void prepare(Client leaderClient, ShardFollowNodeTask task, ShardFollowTask para
107
110
fetchGlobalCheckpoint (leaderClient , leaderShard , leaderGlobalCheckPoint -> {
108
111
// TODO: check if both indices have the same history uuid
109
112
if (leaderGlobalCheckPoint == followGlobalCheckPoint ) {
113
+ logger .debug ("{} no write operations to fetch" , followerShard );
110
114
retry (leaderClient , task , params , followGlobalCheckPoint );
111
115
} else {
112
116
assert followGlobalCheckPoint < leaderGlobalCheckPoint : "followGlobalCheckPoint [" + followGlobalCheckPoint +
113
117
"] is not below leaderGlobalCheckPoint [" + leaderGlobalCheckPoint + "]" ;
118
+ logger .debug ("{} fetching write operations, leaderGlobalCheckPoint={}, followGlobalCheckPoint={}" , followerShard ,
119
+ leaderGlobalCheckPoint , followGlobalCheckPoint );
114
120
Executor ccrExecutor = threadPool .executor (Ccr .CCR_THREAD_POOL_NAME );
115
121
Consumer <Exception > handler = e -> {
116
122
if (e == null ) {
@@ -151,8 +157,7 @@ private void fetchGlobalCheckpoint(Client client, ShardId shardId, LongConsumer
151
157
.findAny ();
152
158
153
159
if (filteredShardStats .isPresent ()) {
154
- // Treat -1 as 0. If no indexing has happened in leader shard then global checkpoint is -1.
155
- final long globalCheckPoint = Math .max (0 , filteredShardStats .get ().getSeqNoStats ().getGlobalCheckpoint ());
160
+ final long globalCheckPoint = filteredShardStats .get ().getSeqNoStats ().getGlobalCheckpoint ();
156
161
handler .accept (globalCheckPoint );
157
162
} else {
158
163
errorHandler .accept (new IllegalArgumentException ("Cannot find shard stats for shard " + shardId ));
@@ -284,7 +289,9 @@ static class ChunkProcessor {
284
289
285
290
void start (final long from , final long to , final long maxTranslogsBytes ) {
286
291
ShardChangesAction .Request request = new ShardChangesAction .Request (leaderShard );
287
- request .setMinSeqNo (from );
292
+ // Treat -1 as 0, because shard changes api min_seq_no is inclusive and therefore it doesn't allow a negative min_seq_no
293
+ // (If no indexing has happened in leader shard then global checkpoint is -1.)
294
+ request .setMinSeqNo (Math .max (0 , from ));
288
295
request .setMaxSeqNo (to );
289
296
request .setMaxTranslogsBytes (maxTranslogsBytes );
290
297
leaderClient .execute (ShardChangesAction .INSTANCE , request , new ActionListener <ShardChangesAction .Response >() {
0 commit comments