HDFS-11915. Sync rbw dir on the first hsync() to avoid file lost on power failure. Contributed by Vinayakumar B.

This commit is contained in:
Wei-Chiu Chuang 2017-12-07 14:50:30 -08:00
parent acb92904d0
commit d6c31a3e6b
1 changed files with 5 additions and 0 deletions

View File

@ -126,6 +126,7 @@ class BlockReceiver implements Closeable {
private boolean syncOnClose;
private volatile boolean dirSyncOnFinalize;
private boolean dirSyncOnHSyncDone = false;
private long restartBudget;
/** the reference of the volume where the block receiver writes to */
private ReplicaHandler replicaHandler;
@ -424,6 +425,10 @@ class BlockReceiver implements Closeable {
}
flushTotalNanos += flushEndNanos - flushStartNanos;
}
if (isSync && !dirSyncOnHSyncDone && replicaInfo instanceof LocalReplica) {
((LocalReplica) replicaInfo).fsyncDirectory();
dirSyncOnHSyncDone = true;
}
if (checksumOut != null || streams.getDataOut() != null) {
datanode.metrics.addFlushNanos(flushTotalNanos);
if (isSync) {