Avoid WAL segment fsync on header write in non-default mode
@@ -1304,16 +1304,19 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
synchronized (this) {
while (locked.containsKey(toArchive) && !stopped)
wait();
+ }
// Firstly, format working file
if (!stopped)
formatFile(res.getOrigWorkFile());
+ synchronized (this) {
// Then increase counter to allow rollover on clean working file
changeLastArchivedIndexAndWakeupCompressor(toArchive);
notifyAll();
}
+
if (evt.isRecordable(EventType.EVT_WAL_SEGMENT_ARCHIVED))
evt.record(new WalSegmentArchivedEvent(cctx.discovery().localNode(),
res.getAbsIdx(), res.getDstArchiveFile()));
@@ -1889,7 +1892,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
* @return I/O position after write version.
* @throws IOException If failed to write serializer version.
*/
- public static long writeSerializerVersion(FileIO io, long idx, int version) throws IOException {
+ public static long writeSerializerVersion(FileIO io, long idx, int version, WALMode mode) throws IOException {
ByteBuffer buffer = prepareSerializerVersionBuffer(idx, version, false);
do {
@@ -1898,6 +1901,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
while (buffer.hasRemaining());
// Flush
+ if (mode == WALMode.DEFAULT)
io.force();
return io.position();
@@ -2205,9 +2209,11 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
*/
public void writeSerializerVersion() throws IgniteCheckedException {
try {
- assert fileIO.position() == 0 : "Serializer version can be written only at the begin of file " + fileIO.position();
+ assert fileIO.position() == 0 : "Serializer version can be written only at the begin of file " +
+ fileIO.position();
- long updatedPosition = FileWriteAheadLogManager.writeSerializerVersion(fileIO, idx, serializer.version());
+ long updatedPosition = FileWriteAheadLogManager.writeSerializerVersion(fileIO, idx,
+ serializer.version(), mode);
written = updatedPosition;
lastFsyncPos = updatedPosition;
