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:
parent
acb92904d0
commit
d6c31a3e6b
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue