Skip to content

Commit c21745c

Browse files
committed
Avoid loading retention leases while writing them (#42620)
Resolves #41430.
1 parent 31d2bdc commit c21745c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ public synchronized void updateRetentionLeasesOnReplica(final RetentionLeases re
346346
* @throws IOException if an I/O exception occurs reading the retention leases
347347
*/
348348
public RetentionLeases loadRetentionLeases(final Path path) throws IOException {
349-
final RetentionLeases retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
349+
final RetentionLeases retentionLeases;
350+
synchronized (retentionLeasePersistenceLock) {
351+
retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
352+
}
350353

351354
// TODO after backporting we expect this never to happen in 8.x, so adjust this to throw an exception instead.
352355
assert Version.CURRENT.major <= 8 : "throw an exception instead of returning EMPTY on null";

0 commit comments

Comments
 (0)