mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Double check if stream must be flush to allow tests to make better assumptions of what is visible and what isn't after tragic events
This commit is contained in:
parent
ea6718d878
commit
dff30ece05
@ -266,7 +266,13 @@ public class TranslogWriter extends TranslogReader {
|
||||
protected void readBytes(ByteBuffer targetBuffer, long position) throws IOException {
|
||||
if (position+targetBuffer.remaining() > getWrittenOffset()) {
|
||||
synchronized (this) {
|
||||
outputStream.flush();
|
||||
// we only flush here if it's really really needed - try to minimize the impact of the read operation
|
||||
// in some cases ie. a tragic event we might still be able to read the relevant value
|
||||
// which is not really important in production but some test can make most strict assumptions
|
||||
// if we don't fail in this call unless absolutely necessary.
|
||||
if (position+targetBuffer.remaining() > getWrittenOffset()) {
|
||||
outputStream.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
// we don't have to have a lock here because we only write ahead to the file, so all writes has been complete
|
||||
|
Loading…
x
Reference in New Issue
Block a user