HBASE-1879 ReadOnly transactions generate WAL activity.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@820888 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-10-02 05:21:47 +00:00
parent 9719bcba95
commit 26cc7e9a23
6 changed files with 11 additions and 36 deletions

View File

@ -90,6 +90,7 @@ Release 0.21.0 - Unreleased
HBASE-1874 Client Scanner mechanism that is used for HbaseAdmin methods HBASE-1874 Client Scanner mechanism that is used for HbaseAdmin methods
(listTables, tableExists), is very slow if the client is far (listTables, tableExists), is very slow if the client is far
away from the HBase cluster (Andrei Dragomir via Stack) away from the HBase cluster (Andrei Dragomir via Stack)
HBASE-1879 ReadOnly transactions generate WAL activity (Clint Morgan via Stack)
OPTIMIZATIONS OPTIMIZATIONS

View File

@ -58,11 +58,6 @@ class THLog extends HLog {
return new THLogKey(regionName, tableName, seqNum, now); return new THLogKey(regionName, tableName, seqNum, now);
} }
public void writeStartToLog(HRegionInfo regionInfo, final long transactionId) throws IOException {
this.append(regionInfo, System.currentTimeMillis(),
THLogKey.TrxOp.START, transactionId);
}
public void writeUpdateToLog(HRegionInfo regionInfo, final long transactionId, final Put update) public void writeUpdateToLog(HRegionInfo regionInfo, final long transactionId, final Put update)
throws IOException { throws IOException {
this.append(regionInfo, update, transactionId); this.append(regionInfo, update, transactionId);

View File

@ -31,8 +31,6 @@ public class THLogKey extends HLogKey {
* *
*/ */
public enum TrxOp { public enum TrxOp {
/** Start a transaction. */
START((byte)1),
/** A standard operation that is transactional. KV holds the op. */ /** A standard operation that is transactional. KV holds the op. */
OP((byte)2), OP((byte)2),
/** A transaction was committed. */ /** A transaction was committed. */

View File

@ -140,23 +140,11 @@ class THLogRecoveryManager {
List<KeyValue> updates = pendingTransactionsById.get(transactionId); List<KeyValue> updates = pendingTransactionsById.get(transactionId);
switch (key.getTrxOp()) { switch (key.getTrxOp()) {
case START:
if (updates != null || abortedTransactions.contains(transactionId)
|| commitedTransactions.contains(transactionId)) {
LOG.error("Processing start for transaction: " + transactionId
+ ", but have already seen start message");
throw new IOException("Corrupted transaction log");
}
updates = new ArrayList<KeyValue>();
pendingTransactionsById.put(transactionId, updates);
startCount++;
break;
case OP: case OP:
if (updates == null) { if (updates == null) {
LOG.error("Processing edit for transaction: " + transactionId updates = new ArrayList<KeyValue>();
+ ", but have not seen start message"); pendingTransactionsById.put(transactionId, updates);
throw new IOException("Corrupted transaction log"); startCount++;
} }
updates.add(val); updates.add(val);

View File

@ -227,7 +227,6 @@ public class TransactionalRegion extends HRegion {
} }
LOG.debug("Begining transaction " + key + " in region " LOG.debug("Begining transaction " + key + " in region "
+ super.getRegionInfo().getRegionNameAsString()); + super.getRegionInfo().getRegionNameAsString());
this.hlog.writeStartToLog(super.getRegionInfo(), transactionId);
maybeTriggerOldTransactionFlush(); maybeTriggerOldTransactionFlush();
} }
@ -449,7 +448,9 @@ public class TransactionalRegion extends HRegion {
state.setStatus(Status.ABORTED); state.setStatus(Status.ABORTED);
this.hlog.writeAbortToLog(super.getRegionInfo(), state.getTransactionId()); if (state.hasWrite()) {
this.hlog.writeAbortToLog(super.getRegionInfo(), state.getTransactionId());
}
// Following removes needed if we have voted // Following removes needed if we have voted
if (state.getSequenceNumber() != null) { if (state.getSequenceNumber() != null) {
@ -475,9 +476,11 @@ public class TransactionalRegion extends HRegion {
this.delete(delete, null, true); this.delete(delete, null, true);
} }
// Now the transaction lives in the WAL, we can writa a commit to the log // Now the transaction lives in the WAL, we can write a commit to the log
// so we don't have to recover it. // so we don't have to recover it.
this.hlog.writeCommitToLog(super.getRegionInfo(), state.getTransactionId()); if (state.hasWrite()) {
this.hlog.writeCommitToLog(super.getRegionInfo(), state.getTransactionId());
}
state.setStatus(Status.COMMITED); state.setStatus(Status.COMMITED);
if (state.hasWrite() if (state.hasWrite()

View File

@ -86,8 +86,6 @@ public class TestTHLog extends HBaseTestCase implements
// Write columns named 1, 2, 3, etc. and then values of single byte // Write columns named 1, 2, 3, etc. and then values of single byte
// 1, 2, 3... // 1, 2, 3...
long transactionId = 1; long transactionId = 1;
log.writeStartToLog(regionInfo, transactionId);
log.writeUpdateToLog(regionInfo, transactionId, new Put(row1).add(family, log.writeUpdateToLog(regionInfo, transactionId, new Put(row1).add(family,
column, val1)); column, val1));
log.writeUpdateToLog(regionInfo, transactionId, new Put(row2).add(family, log.writeUpdateToLog(regionInfo, transactionId, new Put(row2).add(family,
@ -119,8 +117,6 @@ public class TestTHLog extends HBaseTestCase implements
regionInfo, conf); regionInfo, conf);
long transactionId = 1; long transactionId = 1;
log.writeStartToLog(regionInfo, transactionId);
log.writeUpdateToLog(regionInfo, transactionId, new Put(row1).add(family, log.writeUpdateToLog(regionInfo, transactionId, new Put(row1).add(family,
column, val1)); column, val1));
log.writeUpdateToLog(regionInfo, transactionId, new Put(row2).add(family, log.writeUpdateToLog(regionInfo, transactionId, new Put(row2).add(family,
@ -152,11 +148,9 @@ public class TestTHLog extends HBaseTestCase implements
long transaction1Id = 1; long transaction1Id = 1;
long transaction2Id = 2; long transaction2Id = 2;
log.writeStartToLog(regionInfo, transaction1Id);
log.writeUpdateToLog(regionInfo, transaction1Id, new Put(row1).add(family, log.writeUpdateToLog(regionInfo, transaction1Id, new Put(row1).add(family,
column, val1)); column, val1));
log.writeStartToLog(regionInfo, transaction2Id);
log.writeUpdateToLog(regionInfo, transaction2Id, new Put(row2).add(family, log.writeUpdateToLog(regionInfo, transaction2Id, new Put(row2).add(family,
column, val2)); column, val2));
@ -189,11 +183,9 @@ public class TestTHLog extends HBaseTestCase implements
long transaction1Id = 1; long transaction1Id = 1;
long transaction2Id = 2; long transaction2Id = 2;
log.writeStartToLog(regionInfo, transaction1Id);
log.writeUpdateToLog(regionInfo, transaction1Id, new Put(row1).add(family, log.writeUpdateToLog(regionInfo, transaction1Id, new Put(row1).add(family,
column, val1)); column, val1));
log.writeStartToLog(regionInfo, transaction2Id);
log.writeUpdateToLog(regionInfo, transaction2Id, new Put(row2).add(family, log.writeUpdateToLog(regionInfo, transaction2Id, new Put(row2).add(family,
column, val2)); column, val2));
log.writeAbortToLog(regionInfo, transaction2Id); log.writeAbortToLog(regionInfo, transaction2Id);
@ -226,11 +218,9 @@ public class TestTHLog extends HBaseTestCase implements
long transaction1Id = 1; long transaction1Id = 1;
long transaction2Id = 2; long transaction2Id = 2;
log.writeStartToLog(regionInfo, transaction1Id);
log.writeUpdateToLog(regionInfo, transaction1Id, new Put(row1).add(family, log.writeUpdateToLog(regionInfo, transaction1Id, new Put(row1).add(family,
column, val1)); column, val1));
log.writeStartToLog(regionInfo, transaction2Id);
log.writeUpdateToLog(regionInfo, transaction2Id, new Put(row2).add(family, log.writeUpdateToLog(regionInfo, transaction2Id, new Put(row2).add(family,
column, val2)); column, val2));
log.writeCommitToLog(regionInfo, transaction2Id); log.writeCommitToLog(regionInfo, transaction2Id);