HBASE-11028 FSLog: Avoid an extra sync if the current transaction is already sync'd

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1589158 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2014-04-22 15:04:32 +00:00
parent 2513370c3e
commit 5cf62f550f
2 changed files with 9 additions and 5 deletions

View File

@ -1486,8 +1486,11 @@ class FSHLog implements HLog, Syncable {
} }
@Override @Override
// txid is unused. txid is an implementation detail. It should not leak outside of WAL.
public void sync(long txid) throws IOException { public void sync(long txid) throws IOException {
if (this.highestSyncedSequence.get() >= txid){
// Already sync'd.
return;
}
publishSyncThenBlockOnCompletion(); publishSyncThenBlockOnCompletion();
} }

View File

@ -342,16 +342,17 @@ public interface HLog {
void hflush() throws IOException; void hflush() throws IOException;
/**
* Sync what we have in the WAL.
* @throws IOException
*/
void sync() throws IOException; void sync() throws IOException;
/** /**
* Sync the WAL if the txId was not already sync'd.
* @param txid Transaction id to sync to. * @param txid Transaction id to sync to.
* @throws IOException * @throws IOException
* @deprecated Since 0.96.2. Just call {@link #sync()}. <code>txid</code> should not be allowed
* outside the implementation.
*/ */
// TODO: Why is this exposed? txid is an internal detail.
@Deprecated
void sync(long txid) throws IOException; void sync(long txid) throws IOException;
/** /**