HBASE-1148 Always flush HLog on root or meta region updates

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@737241 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2009-01-23 23:09:37 +00:00
parent 542abcf26d
commit 6c78d4e6a6
4 changed files with 14 additions and 11 deletions

View File

@ -10,6 +10,7 @@ Release 0.20.0 - Unreleased
HBASE-1138 Test that readers opened after a sync can see all data up to the
sync (temporary until HADOOP-4379 is resolved)
HBASE-1121 Cluster confused about where -ROOT- is
HBASE-1148 Always flush HLog on root or meta region updates
IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -455,13 +455,12 @@ public class HLog implements HConstants, Syncable {
*
* @param regionName
* @param tableName
* @param row
* @param columns
* @param timestamp
* @param edits
* @param sync
* @throws IOException
*/
void append(byte [] regionName, byte [] tableName,
TreeMap<HStoreKey, byte[]> edits)
TreeMap<HStoreKey, byte[]> edits, boolean sync)
throws IOException {
if (closed) {
throw new IOException("Cannot append; log is closed");
@ -482,7 +481,7 @@ public class HLog implements HConstants, Syncable {
new HLogKey(regionName, tableName, key.getRow(), seqNum[counter++]);
HLogEdit logEdit =
new HLogEdit(key.getColumn(), es.getValue(), key.getTimestamp());
doWrite(logKey, logEdit);
doWrite(logKey, logEdit, sync);
this.numEntries++;
}
@ -520,10 +519,11 @@ public class HLog implements HConstants, Syncable {
}
}
private void doWrite(HLogKey logKey, HLogEdit logEdit) throws IOException {
private void doWrite(HLogKey logKey, HLogEdit logEdit, boolean sync)
throws IOException {
try {
this.writer.append(logKey, logEdit);
if (++unflushedEntries >= flushlogentries) {
if (sync || ++unflushedEntries >= flushlogentries) {
sync();
}
} catch (IOException e) {
@ -569,7 +569,8 @@ public class HLog implements HConstants, Syncable {
}
HLogKey logKey = new HLogKey(regionName, tableName, row, seqNum);
doWrite(logKey, logEdit);
boolean sync = regionInfo.isMetaRegion() || regionInfo.isRootRegion();
doWrite(logKey, logEdit, sync);
this.numEntries++;
updateLock.notifyAll();
}

View File

@ -1707,7 +1707,8 @@ public class HRegion implements HConstants {
try {
if (writeToWAL) {
this.log.append(regionInfo.getRegionName(),
regionInfo.getTableDesc().getName(), updatesByColumn);
regionInfo.getTableDesc().getName(), updatesByColumn,
(regionInfo.isMetaRegion() || regionInfo.isRootRegion()));
}
long size = 0;
for (Map.Entry<HStoreKey, byte[]> e: updatesByColumn.entrySet()) {

View File

@ -77,7 +77,7 @@ public class TestHLog extends HBaseTestCase implements HConstants {
byte [] column = Bytes.toBytes(Integer.toString(j));
edit.put(new HStoreKey(rowName, column, System.currentTimeMillis()),
column);
log.append(Bytes.toBytes(Integer.toString(i)), tableName, edit);
log.append(Bytes.toBytes(Integer.toString(i)), tableName, edit, false);
}
}
log.rollWriter();
@ -110,7 +110,7 @@ public class TestHLog extends HBaseTestCase implements HConstants {
cols.put(new HStoreKey(row, Bytes.toBytes(Integer.toString(i)), timestamp),
new byte[] { (byte)(i + '0') });
}
log.append(regionName, tableName, cols);
log.append(regionName, tableName, cols, false);
long logSeqId = log.startCacheFlush();
log.completeCacheFlush(regionName, tableName, logSeqId);
log.close();