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 2013/04/15 22:42:30 UTC
svn commit: r1468221 - in
/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client:
HConnection.java HConnectionManager.java ServerCallable.java
Author: larsh
Date: Mon Apr 15 20:42:30 2013
New Revision: 1468221
URL: http://svn.apache.org/r1468221
Log:
HBASE-8285 HBaseClient never recovers for single HTable.get() calls with no retries when regions move (Varun Sharma)
Modified:
hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1468221&r1=1468220&r2=1468221&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java Mon Apr 15 20:42:30 2013
@@ -163,6 +163,12 @@ public interface HConnection extends Abo
public void clearRegionCache(final byte [] tableName);
/**
+ * Deletes cached locations for the specific region.
+ * @param location The location object for the region, to be purged from cache.
+ */
+ public void deleteCachedRegionLocation(final HRegionLocation location);
+
+ /**
* Find the location of the region of <i>tableName</i> that <i>row</i>
* lives in, ignoring any value that might be in the cache.
* @param tableName name of the table <i>row</i> is in
Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1468221&r1=1468220&r2=1468221&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Mon Apr 15 20:42:30 2013
@@ -1888,6 +1888,28 @@ public class HConnectionManager {
}
}
+ @Override
+ public void deleteCachedRegionLocation(final HRegionLocation location) {
+ if (location == null) {
+ return;
+ }
+ synchronized (this.cachedRegionLocations) {
+ byte[] tableName = location.getRegionInfo().getTableName();
+ Map<byte[], HRegionLocation> tableLocations = getTableLocations(tableName);
+ if (!tableLocations.isEmpty()) {
+ // Delete if there's something in the cache for this region.
+ HRegionLocation removedLocation =
+ tableLocations.remove(location.getRegionInfo().getStartKey());
+ if (LOG.isDebugEnabled() && removedLocation != null) {
+ LOG.debug("Removed " +
+ location.getRegionInfo().getRegionNameAsString() +
+ " for tableName=" + Bytes.toString(tableName) +
+ " from cache");
+ }
+ }
+ }
+ }
+
/**
* Update the location with the new value (if the exception is a RegionMovedException)
* or delete it from the cache.
Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java?rev=1468221&r1=1468220&r2=1468221&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java Mon Apr 15 20:42:30 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.exceptions.DoNotRetryIOException;
+import org.apache.hadoop.hbase.exceptions.NotServingRegionException;
import org.apache.hadoop.hbase.ipc.HBaseClientRPC;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -181,6 +182,10 @@ public abstract class ServerCallable<T>
// map to that slow/dead server; otherwise, let cache miss and ask
// .META. again to find the new location
getConnection().clearCaches(location.getServerName());
+ } else if (t instanceof NotServingRegionException && numRetries == 1) {
+ // Purge cache entries for this specific region from META cache
+ // since we don't call connect(true) when number of retries is 1.
+ getConnection().deleteCachedRegionLocation(location);
}
RetriesExhaustedException.ThrowableWithExtraContext qt =