HBASE-10344 Improve write performance by ignoring sync to hdfs when an asyncer's writes have been synced by other asyncer
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1558506 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bbf242cdaf
commit
16943fe2ae
|
@ -1203,6 +1203,15 @@ class FSHLog implements HLog, Syncable {
|
||||||
this.txidToSync = this.writtenTxid;
|
this.txidToSync = this.writtenTxid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if this syncer's writes have been synced by other syncer:
|
||||||
|
// 1. just set lastSyncedTxid
|
||||||
|
// 2. don't do real sync, don't notify AsyncNotifier, don't logroll check
|
||||||
|
// regardless of whether the writer is null or not
|
||||||
|
if (this.txidToSync <= syncedTillHere.get()) {
|
||||||
|
this.lastSyncedTxid = this.txidToSync;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 2. do 'sync' to HDFS to provide durability
|
// 2. do 'sync' to HDFS to provide durability
|
||||||
long now = EnvironmentEdgeManager.currentTimeMillis();
|
long now = EnvironmentEdgeManager.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
@ -1221,16 +1230,13 @@ class FSHLog implements HLog, Syncable {
|
||||||
// 6. t6: AsyncSyncer 1 starts to use writer to do sync... before
|
// 6. t6: AsyncSyncer 1 starts to use writer to do sync... before
|
||||||
// rollWriter set writer to the newly created Writer
|
// rollWriter set writer to the newly created Writer
|
||||||
//
|
//
|
||||||
// So when writer == null here:
|
// Now writer == null and txidToSync > syncedTillHere here:
|
||||||
// 1. if txidToSync <= syncedTillHere, can safely ignore sync here;
|
// we need fail all the writes with txid <= txidToSync to avoid
|
||||||
// 2. if txidToSync > syncedTillHere, we need fail all the writes with
|
// 'data loss' where user get successful write response but can't
|
||||||
// txid <= txidToSync to avoid 'data loss' where user get successful
|
// read the writes!
|
||||||
// write response but can't read the writes!
|
LOG.fatal("should never happen: has unsynced writes but writer is null!");
|
||||||
if (this.txidToSync > syncedTillHere.get()) {
|
asyncIOE = new IOException("has unsynced writes but writer is null!");
|
||||||
LOG.fatal("should never happen: has unsynced writes but writer is null!");
|
failedTxid.set(this.txidToSync);
|
||||||
asyncIOE = new IOException("has unsynced writes but writer is null!");
|
|
||||||
failedTxid.set(this.txidToSync);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.isSyncing = true;
|
this.isSyncing = true;
|
||||||
writer.sync();
|
writer.sync();
|
||||||
|
|
Loading…
Reference in New Issue