Translog: close channel on failures while converting a writer to a reader
TranslogWriter.closeIntoReader transfers the file ownership from a writer to a reader and closes the writer. If the transfer fails, we need to make sure we closed the underlying channel as the writer is already closes. See: http://build-us-00.elastic.co/job/es_core_master_regression/4355 Relates to #16142
This commit is contained in:
parent
9110f4f654
commit
fbca68a7c4
|
@ -192,7 +192,13 @@ public class TranslogWriter extends BaseTranslogReader implements Closeable {
|
|||
throw e;
|
||||
}
|
||||
if (closed.compareAndSet(false, true)) {
|
||||
return new TranslogReader(generation, channel, path, firstOperationOffset, getWrittenOffset(), operationCounter);
|
||||
try {
|
||||
return new TranslogReader(generation, channel, path, firstOperationOffset, getWrittenOffset(), operationCounter);
|
||||
} catch (Throwable t) {
|
||||
// close the channel, as we are closed and failed to create a new reader
|
||||
IOUtils.closeWhileHandlingException(channel);
|
||||
throw t;
|
||||
}
|
||||
} else {
|
||||
throw new AlreadyClosedException("translog [" + getGeneration() + "] is already closed (path [" + path + "]", tragedy);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue