Translog: Buffering translog does not write directly to the file channel but to RAF, which causes problems reading from the channel on windows, closes #1887.
This commit is contained in:
parent
0fdfa5a581
commit
cd79f03977
|
@ -57,7 +57,9 @@ public class BufferingFsTranslogFile implements FsTranslogFile {
|
||||||
long position = lastPosition;
|
long position = lastPosition;
|
||||||
if (size >= buffer.length) {
|
if (size >= buffer.length) {
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
raf.raf().write(data, from, size);
|
// we use the channel to write, since on windows, writing to the RAF might not be reflected
|
||||||
|
// when reading through the channel
|
||||||
|
raf.channel().write(ByteBuffer.wrap(data, from, size));
|
||||||
lastWrittenPosition += size;
|
lastWrittenPosition += size;
|
||||||
lastPosition += size;
|
lastPosition += size;
|
||||||
return new Translog.Location(id, position, size);
|
return new Translog.Location(id, position, size);
|
||||||
|
@ -76,7 +78,9 @@ public class BufferingFsTranslogFile implements FsTranslogFile {
|
||||||
|
|
||||||
private void flushBuffer() throws IOException {
|
private void flushBuffer() throws IOException {
|
||||||
if (bufferCount > 0) {
|
if (bufferCount > 0) {
|
||||||
raf.raf().write(buffer, 0, bufferCount);
|
// we use the channel to write, since on windows, writing to the RAF might not be reflected
|
||||||
|
// when reading through the channel
|
||||||
|
raf.channel().write(ByteBuffer.wrap(buffer, 0, bufferCount));
|
||||||
lastWrittenPosition += bufferCount;
|
lastWrittenPosition += bufferCount;
|
||||||
bufferCount = 0;
|
bufferCount = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue