Skip to content

Commit aba62d2

Browse files
limit the old status description append to 1000 characters
1 parent 9cc7494 commit aba62d2

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ private void syncShardStatsOnNewMaster(List<SnapshotsInProgress.Entry> entries)
676676
if (masterShard != null && masterShard.state().completed() == false) {
677677
final IndexShardSnapshotStatus.Copy indexShardSnapshotStatus = localShard.getValue().asCopy();
678678
final Stage stage = indexShardSnapshotStatus.getStage();
679+
final String statusDescription = indexShardSnapshotStatus.getStatusDescription();
680+
final int maxStatusAppend = 1000;
679681
// Master knows about the shard and thinks it has not completed
680682
if (stage == Stage.DONE) {
681683
// but we think the shard is done - we need to make new master know that the shard is done
@@ -689,10 +691,20 @@ private void syncShardStatsOnNewMaster(List<SnapshotsInProgress.Entry> entries)
689691
snapshot.snapshot(),
690692
shardId,
691693
localShard.getValue().getShardSnapshotResult(),
692-
(outcomeInfoString) -> localShard.getValue().updateStatusDescription(Strings.format("""
693-
Data node already successfully finished shard snapshot, but a new master needed to be notified. New
694-
remote master notification outcome: [%s]. The prior shard snapshot status description was [%s]
695-
""", outcomeInfoString, indexShardSnapshotStatus.getStatusDescription()))
694+
(outcomeInfoString) -> localShard.getValue()
695+
.updateStatusDescription(
696+
Strings.format(
697+
"""
698+
Data node already successfully finished shard snapshot, but a new master needed to be
699+
notified. New remote master notification outcome: [%s]. The prior shard snapshot status
700+
description was [%s]
701+
""",
702+
outcomeInfoString,
703+
statusDescription.length() < maxStatusAppend
704+
? statusDescription
705+
: statusDescription.substring(0, maxStatusAppend)
706+
)
707+
)
696708
);
697709
} else if (stage == Stage.FAILURE) {
698710
// but we think the shard failed - we need to make new master know that the shard failed
@@ -710,10 +722,19 @@ private void syncShardStatsOnNewMaster(List<SnapshotsInProgress.Entry> entries)
710722
localShard.getValue().generation(),
711723
// Update the original statusDescription with the latest remote master call outcome, but include the old
712724
// response. This will allow us to see when/whether the information reached the previous and current master.
713-
(outcomeInfoString) -> localShard.getValue().updateStatusDescription(Strings.format("""
714-
Data node already failed shard snapshot, but a new master needed to be notified. New remote master
715-
notification outcome: [%s]. The prior shard snapshot status description was [%s]
716-
""", outcomeInfoString, indexShardSnapshotStatus.getStatusDescription()))
725+
(outcomeInfoString) -> localShard.getValue()
726+
.updateStatusDescription(
727+
Strings.format(
728+
"""
729+
Data node already failed shard snapshot, but a new master needed to be notified. New remote
730+
master notification outcome: [%s]. The prior shard snapshot status description was [%s]
731+
""",
732+
outcomeInfoString,
733+
statusDescription.length() < maxStatusAppend
734+
? statusDescription
735+
: statusDescription.substring(0, maxStatusAppend)
736+
)
737+
)
717738
);
718739
} else if (stage == Stage.PAUSED) {
719740
// but we think the shard has paused - we need to make new master know that
@@ -727,10 +748,19 @@ private void syncShardStatsOnNewMaster(List<SnapshotsInProgress.Entry> entries)
727748
ShardState.PAUSED_FOR_NODE_REMOVAL,
728749
indexShardSnapshotStatus.getFailure(),
729750
localShard.getValue().generation(),
730-
(outcomeInfoString) -> localShard.getValue().updateStatusDescription(Strings.format("""
731-
Data node already paused shard snapshot, but a new master needed to be notified. New remote
732-
master notification outcome: [%s]. The prior shard snapshot status description was [%s]
733-
""", outcomeInfoString, indexShardSnapshotStatus.getStatusDescription()))
751+
(outcomeInfoString) -> localShard.getValue()
752+
.updateStatusDescription(
753+
Strings.format(
754+
"""
755+
Data node already paused shard snapshot, but a new master needed to be notified. New remote
756+
master notification outcome: [%s]. The prior shard snapshot status description was [%s]
757+
""",
758+
outcomeInfoString,
759+
statusDescription.length() < maxStatusAppend
760+
? statusDescription
761+
: statusDescription.substring(0, maxStatusAppend)
762+
)
763+
)
734764
);
735765
}
736766
}

0 commit comments

Comments
 (0)