You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2012/05/04 02:00:43 UTC
svn commit: r1333689 - in
/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver:
HRegion.java HRegionServer.java metrics/RegionServerMetrics.java
Author: larsh
Date: Fri May 4 00:00:43 2012
New Revision: 1333689
URL: http://svn.apache.org/viewvc?rev=1333689&view=rev
Log:
HBASE-5886 Add new metric for possible data loss due to puts without WAL
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1333689&r1=1333688&r2=1333689&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri May 4 00:00:43 2012
@@ -214,6 +214,10 @@ public class HRegion implements HeapSize
final AtomicLong memstoreSize = new AtomicLong(0);
+ // Debug possible data loss due to WAL off
+ final AtomicLong numPutsWithoutWAL = new AtomicLong(0);
+ final AtomicLong dataInMemoryWithoutWAL = new AtomicLong(0);
+
final Counter readRequestsCount = new Counter();
final Counter writeRequestsCount = new Counter();
@@ -1249,6 +1253,10 @@ public class HRegion implements HeapSize
status.setStatus("Running coprocessor pre-flush hooks");
coprocessorHost.preFlush();
}
+ if (numPutsWithoutWAL.get() > 0) {
+ numPutsWithoutWAL.set(0);
+ dataInMemoryWithoutWAL.set(0);
+ }
synchronized (writestate) {
if (!writestate.flushing && writestate.writesEnabled) {
this.writestate.flushing = true;
@@ -2098,7 +2106,10 @@ public class HRegion implements HeapSize
batchOp.retCodeDetails[i] = OperationStatus.SUCCESS;
Put p = batchOp.operations[i].getFirst();
- if (!p.getWriteToWAL()) continue;
+ if (!p.getWriteToWAL()) {
+ recordPutWithoutWal(p.getFamilyMap());
+ continue;
+ }
// Add WAL edits by CP
WALEdit fromCP = batchOp.walEditsFromCoprocessors[i];
if (fromCP != null) {
@@ -2430,6 +2441,8 @@ public class HRegion implements HeapSize
addFamilyMapToWALEdit(familyMap, walEdit);
this.log.append(regionInfo, this.htableDescriptor.getName(),
walEdit, clusterId, now, this.htableDescriptor);
+ } else {
+ recordPutWithoutWal(familyMap);
}
long addedSize = applyFamilyMapToMemstore(familyMap, null);
@@ -4648,14 +4661,14 @@ public class HRegion implements HeapSize
public static final long FIXED_OVERHEAD = ClassSize.align(
ClassSize.OBJECT +
ClassSize.ARRAY +
- 32 * ClassSize.REFERENCE + Bytes.SIZEOF_INT +
+ 34 * ClassSize.REFERENCE + Bytes.SIZEOF_INT +
(5 * Bytes.SIZEOF_LONG) +
Bytes.SIZEOF_BOOLEAN);
public static final long DEEP_OVERHEAD = FIXED_OVERHEAD +
ClassSize.OBJECT + // closeLock
(2 * ClassSize.ATOMIC_BOOLEAN) + // closed, closing
- ClassSize.ATOMIC_LONG + // memStoreSize
+ (3 * ClassSize.ATOMIC_LONG) + // memStoreSize, numPutsWithoutWAL, dataInMemoryWithoutWAL
ClassSize.ATOMIC_INTEGER + // lockIdGenerator
(3 * ClassSize.CONCURRENT_HASHMAP) + // lockedRows, lockIds, scannerReadPoints
WriteState.HEAP_SIZE + // writestate
@@ -5004,6 +5017,26 @@ public class HRegion implements HeapSize
}
/**
+ * Update counters for numer of puts without wal and the size of possible data loss.
+ * These information are exposed by the region server metrics.
+ */
+ private void recordPutWithoutWal(final Map<byte [], List<KeyValue>> familyMap) {
+ if (numPutsWithoutWAL.getAndIncrement() == 0) {
+ LOG.info("writing data to region " + this +
+ " with WAL disabled. Data may be lost in the event of a crash.");
+ }
+
+ long putSize = 0;
+ for (List<KeyValue> edits : familyMap.values()) {
+ for (KeyValue kv : edits) {
+ putSize += kv.getKeyLength() + kv.getValueLength();
+ }
+ }
+
+ dataInMemoryWithoutWAL.addAndGet(putSize);
+ }
+
+ /**
* A mocked list implementaion - discards all updates.
*/
private static final List<KeyValue> MOCKED_LIST = new AbstractList<KeyValue>() {
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1333689&r1=1333688&r2=1333689&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Fri May 4 00:00:43 2012
@@ -1325,6 +1325,8 @@ public class HRegionServer implements HR
new HDFSBlocksDistribution();
long totalStaticIndexSize = 0;
long totalStaticBloomSize = 0;
+ long numPutsWithoutWAL = 0;
+ long dataInMemoryWithoutWAL = 0;
// Note that this is a map of Doubles instead of Longs. This is because we
// do effective integer division, which would perhaps truncate more than it
@@ -1337,6 +1339,8 @@ public class HRegionServer implements HR
for (Map.Entry<String, HRegion> e : this.onlineRegions.entrySet()) {
HRegion r = e.getValue();
memstoreSize += r.memstoreSize.get();
+ numPutsWithoutWAL += r.numPutsWithoutWAL.get();
+ dataInMemoryWithoutWAL += r.dataInMemoryWithoutWAL.get();
readRequestsCount += r.readRequestsCount.get();
writeRequestsCount += r.writeRequestsCount.get();
synchronized (r.stores) {
@@ -1400,6 +1404,8 @@ public class HRegionServer implements HR
this.metrics.stores.set(stores);
this.metrics.storefiles.set(storefiles);
this.metrics.memstoreSizeMB.set((int) (memstoreSize / (1024 * 1024)));
+ this.metrics.mbInMemoryWithoutWAL.set((int) (dataInMemoryWithoutWAL / (1024 * 1024)));
+ this.metrics.numPutsWithoutWAL.set(numPutsWithoutWAL);
this.metrics.storefileIndexSizeMB.set(
(int) (storefileIndexSize / (1024 * 1024)));
this.metrics.rootIndexSizeKB.set(
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java?rev=1333689&r1=1333688&r2=1333689&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java Fri May 4 00:00:43 2012
@@ -207,6 +207,18 @@ public class RegionServerMetrics impleme
new MetricsIntValue("memstoreSizeMB", registry);
/**
+ * Number of put with WAL disabled in this regionserver in MB
+ */
+ public final MetricsLongValue numPutsWithoutWAL =
+ new MetricsLongValue("numPutsWithoutWAL", registry);
+
+ /**
+ * Possible data loss sizes (due to put with WAL disabled) in this regionserver in MB
+ */
+ public final MetricsIntValue mbInMemoryWithoutWAL =
+ new MetricsIntValue("mbInMemoryWithoutWAL", registry);
+
+ /**
* Size of the compaction queue.
*/
public final MetricsIntValue compactionQueueSize =
@@ -363,6 +375,8 @@ public class RegionServerMetrics impleme
this.totalStaticIndexSizeKB.pushMetric(this.metricsRecord);
this.totalStaticBloomSizeKB.pushMetric(this.metricsRecord);
this.memstoreSizeMB.pushMetric(this.metricsRecord);
+ this.mbInMemoryWithoutWAL.pushMetric(this.metricsRecord);
+ this.numPutsWithoutWAL.pushMetric(this.metricsRecord);
this.readRequestsCount.pushMetric(this.metricsRecord);
this.writeRequestsCount.pushMetric(this.metricsRecord);
this.regions.pushMetric(this.metricsRecord);
@@ -532,6 +546,10 @@ public class RegionServerMetrics impleme
Integer.valueOf(this.totalStaticBloomSizeKB.get()));
sb = Strings.appendKeyValue(sb, this.memstoreSizeMB.getName(),
Integer.valueOf(this.memstoreSizeMB.get()));
+ sb = Strings.appendKeyValue(sb, "mbInMemoryWithoutWAL",
+ Integer.valueOf(this.mbInMemoryWithoutWAL.get()));
+ sb = Strings.appendKeyValue(sb, "numberOfPutsWithoutWAL",
+ Long.valueOf(this.numPutsWithoutWAL.get()));
sb = Strings.appendKeyValue(sb, "readRequestsCount",
Long.valueOf(this.readRequestsCount.get()));
sb = Strings.appendKeyValue(sb, "writeRequestsCount",