Skip to content

Commit f0ff5fe

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

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
@@ -343,7 +343,10 @@ public synchronized void updateRetentionLeasesOnReplica(final RetentionLeases re
343343
* @throws IOException if an I/O exception occurs reading the retention leases
344344
*/
345345
public RetentionLeases loadRetentionLeases(final Path path) throws IOException {
346-
final RetentionLeases retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
346+
final RetentionLeases retentionLeases;
347+
synchronized (retentionLeasePersistenceLock) {
348+
retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
349+
}
347350

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

0 commit comments

Comments
 (0)