Avoid loading retention leases while writing them (#42620)

Resolves #41430.
This commit is contained in:
David Turner 2019-05-28 15:23:55 +01:00
parent 31d2bdca37
commit c21745c8ab
1 changed files with 4 additions and 1 deletions

View File

@ -346,7 +346,10 @@ public class ReplicationTracker extends AbstractIndexShardComponent implements L
* @throws IOException if an I/O exception occurs reading the retention leases
*/
public RetentionLeases loadRetentionLeases(final Path path) throws IOException {
final RetentionLeases retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
final RetentionLeases retentionLeases;
synchronized (retentionLeasePersistenceLock) {
retentionLeases = RetentionLeases.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
}
// TODO after backporting we expect this never to happen in 8.x, so adjust this to throw an exception instead.
assert Version.CURRENT.major <= 8 : "throw an exception instead of returning EMPTY on null";