From 16943fe2ae25d79a08e87e547cb90d0cc29d9f76 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 15 Jan 2014 18:49:55 +0000 Subject: [PATCH] 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 --- .../hadoop/hbase/regionserver/wal/FSHLog.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index e9727d7dd89..190bb4ef40a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -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();