@@ -151,18 +151,9 @@ protected void innerUpdateMapping(long minRequiredMappingVersion, LongConsumer h
151
151
final Index followerIndex = params .getFollowShardId ().getIndex ();
152
152
final Index leaderIndex = params .getLeaderShardId ().getIndex ();
153
153
final Supplier <TimeValue > timeout = () -> isStopped () ? TimeValue .MINUS_ONE : waitForMetadataTimeOut ;
154
-
155
- final Client remoteClient ;
156
- try {
157
- remoteClient = remoteClient (params );
158
- } catch (NoSuchRemoteClusterException e ) {
159
- errorHandler .accept (e );
160
- return ;
161
- }
162
-
163
- CcrRequests .getIndexMetadata (remoteClient , leaderIndex , minRequiredMappingVersion , 0L , timeout , ActionListener .wrap (
154
+ final ActionListener <IndexMetaData > listener = ActionListener .wrap (
164
155
indexMetaData -> {
165
- if (indexMetaData .getMappings (). isEmpty () ) {
156
+ if (indexMetaData .mapping () == null ) {
166
157
assert indexMetaData .getMappingVersion () == 1 ;
167
158
handler .accept (indexMetaData .getMappingVersion ());
168
159
return ;
@@ -176,7 +167,12 @@ protected void innerUpdateMapping(long minRequiredMappingVersion, LongConsumer h
176
167
errorHandler ));
177
168
},
178
169
errorHandler
179
- ));
170
+ );
171
+ try {
172
+ CcrRequests .getIndexMetadata (remoteClient (params ), leaderIndex , minRequiredMappingVersion , 0L , timeout , listener );
173
+ } catch (NoSuchRemoteClusterException e ) {
174
+ errorHandler .accept (e );
175
+ }
180
176
}
181
177
182
178
@ Override
@@ -445,21 +441,27 @@ protected Scheduler.Cancellable scheduleBackgroundRetentionLeaseRenewal(final Lo
445
441
"{} background adding retention lease [{}] while following" ,
446
442
params .getFollowShardId (),
447
443
retentionLeaseId );
448
- CcrRetentionLeases .asyncAddRetentionLease (
444
+ try {
445
+ final ActionListener <RetentionLeaseActions .Response > wrappedListener = ActionListener .wrap (
446
+ r -> {},
447
+ inner -> {
448
+ /*
449
+ * If this fails that the retention lease already exists, something highly unusual is
450
+ * going on. Log it, and renew again after another renew interval has passed.
451
+ */
452
+ final Throwable innerCause = ExceptionsHelper .unwrapCause (inner );
453
+ logRetentionLeaseFailure (retentionLeaseId , innerCause );
454
+ });
455
+ CcrRetentionLeases .asyncAddRetentionLease (
449
456
params .getLeaderShardId (),
450
457
retentionLeaseId ,
451
458
followerGlobalCheckpoint .getAsLong (),
452
459
remoteClient (params ),
453
- ActionListener .wrap (
454
- r -> {},
455
- inner -> {
456
- /*
457
- * If this fails that the retention lease already exists, something highly unusual is
458
- * going on. Log it, and renew again after another renew interval has passed.
459
- */
460
- final Throwable innerCause = ExceptionsHelper .unwrapCause (inner );
461
- logRetentionLeaseFailure (retentionLeaseId , innerCause );
462
- }));
460
+ wrappedListener );
461
+ } catch (NoSuchRemoteClusterException rce ) {
462
+ // we will attempt to renew again after another renew interval has passed
463
+ logRetentionLeaseFailure (retentionLeaseId , rce );
464
+ }
463
465
} else {
464
466
// if something else happened, we will attempt to renew again after another renew interval has passed
465
467
}
0 commit comments