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:41:23 UTC
svn commit: r1468218 - in
/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client:
HConnection.java HConnectionManager.java ServerCallable.java
Author: larsh
Date: Mon Apr 15 20:41:23 2013
New Revision: 1468218
URL: http://svn.apache.org/r1468218
Log:
HBASE-8285 HBaseClient never recovers for single HTable.get() calls with no retries when regions move (Varun Sharma)
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1468218&r1=1468217&r2=1468218&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnection.java Mon Apr 15 20:41:23 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/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1468218&r1=1468217&r2=1468218&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Mon Apr 15 20:41:23 2013
@@ -1172,11 +1172,10 @@ public class HConnectionManager {
*/
void deleteCachedLocation(final byte [] tableName, final byte [] row) {
synchronized (this.cachedRegionLocations) {
- Map<byte[], HRegionLocation> tableLocations =
- getTableLocations(tableName);
- // start to examine the cache. we can only do cache actions
- // if there's something in the cache for this table.
+ Map<byte[], HRegionLocation> tableLocations = getTableLocations(tableName);
if (!tableLocations.isEmpty()) {
+ // start to examine the cache. we can only do cache actions
+ // if there's something in the cache for this table.
HRegionLocation rl = getCachedLocation(tableName, row);
if (rl != null) {
tableLocations.remove(rl.getRegionInfo().getStartKey());
@@ -1192,6 +1191,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");
+ }
+ }
+ }
+ }
+
+ @Override
public void clearCaches(String sn) {
clearCachedLocationForServer(sn);
}
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java?rev=1468218&r1=1468217&r2=1468218&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java Mon Apr 15 20:41:23 2013
@@ -32,6 +32,7 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.ipc.HBaseRPC;
import org.apache.hadoop.hbase.ipc.HRegionInterface;
import org.apache.hadoop.hbase.util.Bytes;
@@ -174,6 +175,10 @@ public abstract class ServerCallable<T>
if (hrl != null) {
getConnection().clearCaches(hrl.getHostnamePort());
}
+ } 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 =
new RetriesExhaustedException.ThrowableWithExtraContext(t,