Skip to content

Commit 69d757c

Browse files
committed
Enhance logging messages
1 parent 086e87e commit 69d757c

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void onFailure(final Exception e) {
115115
}
116116

117117
@Override
118-
protected Response shardOperation(final T request, final ShardId shardId) throws IOException {
118+
protected Response shardOperation(final T request, final ShardId shardId) {
119119
throw new UnsupportedOperationException();
120120
}
121121

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,19 @@ public void restoreShard(IndexShard indexShard, SnapshotId snapshotId, Version v
325325
// schedule renewals to run during the restore
326326
final Scheduler.Cancellable renewable = threadPool.scheduleWithFixedDelay(
327327
() -> {
328-
logger.trace("{} background renewal of retention lease during restore", shardId);
328+
logger.trace("{} background renewal of retention lease [{}] during restore", shardId, retentionLeaseId);
329329
final ThreadContext threadContext = threadPool.getThreadContext();
330330
try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
331331
// we have to execute under the system context so that if security is enabled the renewal is authorized
332332
threadContext.markAsSystemContext();
333333
renewRetentionLease(leaderShardId, retentionLeaseId, remoteClient);
334334
} catch (final Exception e) {
335335
assert e instanceof ElasticsearchSecurityException == false : e;
336-
logger.warn(new ParameterizedMessage("{} background renewal of retention lease failed during restore", shardId), e);
336+
logger.warn(new ParameterizedMessage(
337+
"{} background renewal of retention lease [{}] failed during restore",
338+
shardId,
339+
retentionLeaseId),
340+
e);
337341
throw e;
338342
}
339343
},
@@ -375,12 +379,19 @@ void acquireRetentionLeaseOnLeader(
375379
final Optional<RetentionLeaseAlreadyExistsException> maybeAddAlready =
376380
addRetentionLease(leaderShardId, retentionLeaseId, remoteClient);
377381
maybeAddAlready.ifPresent(addAlready -> {
378-
logger.trace(() -> new ParameterizedMessage("{} retention lease already exists, requesting a renewal", shardId), addAlready);
382+
logger.trace(() -> new ParameterizedMessage(
383+
"{} retention lease [{}] already exists, requesting a renewal",
384+
shardId,
385+
retentionLeaseId),
386+
addAlready);
379387
final Optional<RetentionLeaseNotFoundException> maybeRenewNotFound =
380388
renewRetentionLease(leaderShardId, retentionLeaseId, remoteClient);
381389
maybeRenewNotFound.ifPresent(renewNotFound -> {
382390
logger.trace(() -> new ParameterizedMessage(
383-
"{} retention lease not found while attempting to renew, requesting a final add", shardId), renewNotFound);
391+
"{} retention lease [{}] not found while attempting to renew, requesting a final add",
392+
shardId,
393+
retentionLeaseId),
394+
renewNotFound);
384395
final Optional<RetentionLeaseAlreadyExistsException> maybeFallbackAddAlready =
385396
addRetentionLease(leaderShardId, retentionLeaseId, remoteClient);
386397
maybeFallbackAddAlready.ifPresent(fallbackAddAlready -> {

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void testRetentionLeaseIsTakenAtTheStartOfRecovery() throws Exception {
154154
// ensure that a retention lease has been put in place on each shard
155155
assertBusy(() -> {
156156
final IndicesStatsResponse stats =
157-
leaderClient().admin().indices().stats(new IndicesStatsRequest().indices(leaderIndex)).actionGet();
157+
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
158158
assertNotNull(stats.getShards());
159159
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
160160
final List<ShardStats> shardStats = getShardStats(stats);
@@ -231,7 +231,7 @@ public void testRetentionLeaseIsRenewedDuringRecovery() throws Exception {
231231
assertBusy(() -> {
232232
retentionLeases.clear();
233233
final IndicesStatsResponse stats =
234-
leaderClient().admin().indices().stats(new IndicesStatsRequest().indices(leaderIndex)).actionGet();
234+
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
235235
assertNotNull(stats.getShards());
236236
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
237237
final List<ShardStats> shardStats = getShardStats(stats);
@@ -251,7 +251,7 @@ public void testRetentionLeaseIsRenewedDuringRecovery() throws Exception {
251251
// now ensure that the retention leases are being renewed
252252
assertBusy(() -> {
253253
final IndicesStatsResponse stats =
254-
leaderClient().admin().indices().stats(new IndicesStatsRequest().indices(leaderIndex)).actionGet();
254+
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
255255
assertNotNull(stats.getShards());
256256
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
257257
final List<ShardStats> shardStats = getShardStats(stats);
@@ -316,7 +316,7 @@ public void testRetentionLeasesAreNotBeingRenewedAfterRecoveryCompletes() throws
316316
assertBusy(() -> {
317317
retentionLeases.clear();
318318
final IndicesStatsResponse stats =
319-
leaderClient().admin().indices().stats(new IndicesStatsRequest().indices(leaderIndex)).actionGet();
319+
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
320320
assertNotNull(stats.getShards());
321321
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
322322
final List<ShardStats> shardStats = getShardStats(stats);
@@ -346,7 +346,7 @@ public void testRetentionLeasesAreNotBeingRenewedAfterRecoveryCompletes() throws
346346
// now ensure that the retention leases are the same
347347
assertBusy(() -> {
348348
final IndicesStatsResponse stats =
349-
leaderClient().admin().indices().stats(new IndicesStatsRequest().indices(leaderIndex)).actionGet();
349+
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
350350
assertNotNull(stats.getShards());
351351
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
352352
final List<ShardStats> shardStats = getShardStats(stats);

0 commit comments

Comments
 (0)