ARTEMIS-2414 Sync before closing file in case data loss

This commit is contained in:
yang wei 2019-07-05 11:32:40 +08:00 committed by
parent 1eaf12b8e1
commit dd62be1602
2 changed files with 4 additions and 0 deletions

View File

@ -361,6 +361,8 @@ final class MappedSequentialFile implements SequentialFile {
@Override
public void close(boolean waitOnSync) {
if (this.mappedFile != null) {
if (factory.isDatasync())
this.mappedFile.force();
this.mappedFile.close();
this.mappedFile = null;
}

View File

@ -135,6 +135,8 @@ public class NIOSequentialFile extends AbstractSequentialFile {
try {
if (channel != null) {
if (factory.isDatasync())
channel.force(false);
channel.close();
}
} catch (ClosedChannelException e) {