HBASE-8208 In some situations data is not replicated to slaves when deferredLogSync is enabled (Jeffrey Zhong)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1465176 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
larsh 2013-04-06 03:18:27 +00:00
parent f6857d59ef
commit 02c22a449f
2 changed files with 19 additions and 7 deletions

View File

@ -1447,6 +1447,12 @@ public class HRegion implements HeapSize { // , Writable{
status.setStatus(s); status.setStatus(s);
LOG.debug(s); LOG.debug(s);
// sync unflushed WAL changes when deferred log sync is enabled
// see HBASE-8208 for details
if (wal != null && isDeferredLogSyncEnabled()) {
wal.sync();
}
// wait for all in-progress transactions to commit to HLog before // wait for all in-progress transactions to commit to HLog before
// we can start the flush. This prevents // we can start the flush. This prevents
// uncommitted transactions from being written into HFiles. // uncommitted transactions from being written into HFiles.
@ -5333,12 +5339,18 @@ public class HRegion implements HeapSize { // , Writable{
* @throws IOException If anything goes wrong with DFS * @throws IOException If anything goes wrong with DFS
*/ */
private void syncOrDefer(long txid) throws IOException { private void syncOrDefer(long txid) throws IOException {
if (this.getRegionInfo().isMetaRegion() || if (this.getRegionInfo().isMetaRegion() || !isDeferredLogSyncEnabled()) {
!this.htableDescriptor.isDeferredLogFlush() || this.deferredLogSyncDisabled) {
this.log.sync(txid); this.log.sync(txid);
} }
} }
/**
* check if current region is deferred sync enabled.
*/
private boolean isDeferredLogSyncEnabled() {
return (this.htableDescriptor.isDeferredLogFlush() && !this.deferredLogSyncDisabled);
}
/** /**
* A mocked list implementaion - discards all updates. * A mocked list implementaion - discards all updates.
*/ */

View File

@ -1071,6 +1071,11 @@ class FSHLog implements HLog, Syncable {
// sync all transactions upto the specified txid // sync all transactions upto the specified txid
private void syncer(long txid) throws IOException { private void syncer(long txid) throws IOException {
// if the transaction that we are interested in is already
// synced, then return immediately.
if (txid <= this.syncedTillHere) {
return;
}
Writer tempWriter; Writer tempWriter;
synchronized (this.updateLock) { synchronized (this.updateLock) {
if (this.closed) return; if (this.closed) return;
@ -1080,11 +1085,6 @@ class FSHLog implements HLog, Syncable {
// See HBASE-4387, HBASE-5623, HBASE-7329. // See HBASE-4387, HBASE-5623, HBASE-7329.
tempWriter = this.writer; tempWriter = this.writer;
} }
// if the transaction that we are interested in is already
// synced, then return immediately.
if (txid <= this.syncedTillHere) {
return;
}
try { try {
long doneUpto; long doneUpto;
long now = EnvironmentEdgeManager.currentTimeMillis(); long now = EnvironmentEdgeManager.currentTimeMillis();