You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2008/06/26 06:33:43 UTC
svn commit: r671724 - in /hadoop/hbase/branches/0.1: CHANGES.txt
src/java/org/apache/hadoop/hbase/HRegion.java
src/java/org/apache/hadoop/hbase/HRegionInfo.java
Author: stack
Date: Wed Jun 25 21:33:43 2008
New Revision: 671724
URL: http://svn.apache.org/viewvc?rev=671724&view=rev
Log:
HBASE-710 If clocks are way off, then we can have daughter split come before rather than after its parent in .META.
Modified:
hadoop/hbase/branches/0.1/CHANGES.txt
hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java
hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegionInfo.java
Modified: hadoop/hbase/branches/0.1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/CHANGES.txt?rev=671724&r1=671723&r2=671724&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.1/CHANGES.txt Wed Jun 25 21:33:43 2008
@@ -26,6 +26,8 @@
HBASE-613 Timestamp-anchored scanning fails to find all records
HBASE-709 Deadlock while rolling WAL-log while finishing flush
HBASE-707 High-load import of data into single table/family never triggers split
+ HBASE-710 If clocks are way off, then we can have daughter split come
+ before rather than after its parent in .META.
Release 0.1.2 - 05/13/2008
Modified: hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java?rev=671724&r1=671723&r2=671724&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java (original)
+++ hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java Wed Jun 25 21:33:43 2008
@@ -740,14 +740,22 @@
LOG.debug("Endkey and midkey are same, not splitting");
return null;
}
+ // Calculate regionid to use. Can't be less than that of parent else
+ // it'll insert into wrong location over in .META. table: HBASE-710.
+ long rid = System.currentTimeMillis();
+ if (rid < this.regionInfo.getRegionId()) {
+ LOG.warn("Clock skew; parent regions id is " +
+ this.regionInfo.getRegionId() + " but current time here is " + rid);
+ rid = this.regionInfo.getRegionId() + 1;
+ }
HRegionInfo regionAInfo = new HRegionInfo(this.regionInfo.getTableDesc(),
- startKey, midKey);
+ startKey, midKey, false, rid);
Path dirA = new Path(splits, regionAInfo.getEncodedName());
if(fs.exists(dirA)) {
throw new IOException("Cannot split; target file collision at " + dirA);
}
HRegionInfo regionBInfo = new HRegionInfo(this.regionInfo.getTableDesc(),
- midKey, endKey);
+ midKey, endKey, false, rid);
Path dirB = new Path(splits, regionBInfo.getEncodedName());
if(this.fs.exists(dirB)) {
throw new IOException("Cannot split; target file collision at " + dirB);
Modified: hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegionInfo.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegionInfo.java?rev=671724&r1=671723&r2=671724&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegionInfo.java (original)
+++ hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegionInfo.java Wed Jun 25 21:33:43 2008
@@ -140,31 +140,43 @@
* @throws IllegalArgumentException
*/
public HRegionInfo(HTableDescriptor tableDesc, Text startKey, Text endKey,
- final boolean split) throws IllegalArgumentException {
+ final boolean split)
+ throws IllegalArgumentException {
+ this(tableDesc, startKey, endKey, split, System.currentTimeMillis());
+ }
+
+ /**
+ * Construct HRegionInfo with explicit parameters
+ *
+ * @param tableDesc the table descriptor
+ * @param startKey first key in region
+ * @param endKey end of key range
+ * @param split true if this region has split and we have daughter regions
+ * regions that may or may not hold references to this region.
+ * @param regionid Region id to use.
+ * @throws IllegalArgumentException
+ */
+ public HRegionInfo(HTableDescriptor tableDesc, Text startKey, Text endKey,
+ final boolean split, final long regionid)
+ throws IllegalArgumentException {
if(tableDesc == null) {
throw new IllegalArgumentException("tableDesc cannot be null");
}
-
this.endKey = new Text();
if(endKey != null) {
this.endKey.set(endKey);
}
-
this.offLine = false;
- this.regionId = System.currentTimeMillis();
-
+ this.regionId = regionid;
this.regionName = new Text(tableDesc.getName().toString() + DELIMITER +
(startKey == null ? "" : startKey.toString()) + DELIMITER +
regionId);
-
this.split = split;
-
this.startKey = new Text();
if(startKey != null) {
this.startKey.set(startKey);
}
-
this.tableDesc = tableDesc;
setHashCode();
}