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;
|
||||
}
|
||||
|
||||
// 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
|
||||
long now = EnvironmentEdgeManager.currentTimeMillis();
|
||||
try {
|
||||
|
@ -1221,16 +1230,13 @@ class FSHLog implements HLog, Syncable {
|
|||
// 6. t6: AsyncSyncer 1 starts to use writer to do sync... before
|
||||
// rollWriter set writer to the newly created Writer
|
||||
//
|
||||
// So when writer == null here:
|
||||
// 1. if txidToSync <= syncedTillHere, can safely ignore sync here;
|
||||
// 2. if txidToSync > syncedTillHere, we need fail all the writes with
|
||||
// txid <= txidToSync to avoid 'data loss' where user get successful
|
||||
// write response but can't read the writes!
|
||||
if (this.txidToSync > syncedTillHere.get()) {
|
||||
LOG.fatal("should never happen: has unsynced writes but writer is null!");
|
||||
asyncIOE = new IOException("has unsynced writes but writer is null!");
|
||||
failedTxid.set(this.txidToSync);
|
||||
}
|
||||
// Now writer == null and txidToSync > syncedTillHere here:
|
||||
// we need fail all the writes with txid <= txidToSync to avoid
|
||||
// 'data loss' where user get successful write response but can't
|
||||
// read the writes!
|
||||
LOG.fatal("should never happen: has unsynced writes but writer is null!");
|
||||
asyncIOE = new IOException("has unsynced writes but writer is null!");
|
||||
failedTxid.set(this.txidToSync);
|
||||
} else {
|
||||
this.isSyncing = true;
|
||||
writer.sync();
|
||||
|
|
Loading…
Reference in New Issue