Skip to content

Commit bcf1279

Browse files
committed
Avoid loading retention leases while writing them (#42620)
Resolves #41430.
1 parent 861c447 commit bcf1279

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ public synchronized void updateRetentionLeasesOnReplica(final RetentionLeases re
341341
* @throws IOException if an I/O exception occurs reading the retention leases
342342
*/
343343
public RetentionLeases loadRetentionLeases(final Path path) throws IOException {
344-
final RetentionLeases retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
344+
final RetentionLeases retentionLeases;
345+
synchronized (retentionLeasePersistenceLock) {
346+
retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
347+
}
345348

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

0 commit comments

Comments
 (0)