Skip to content

Commit e047929

Browse files
Huaxiang Sunhuaxiangsun
authored andcommitted
Revert "HBASE-25293 Followup jira to address the client handling issue when chaning from meta replica to non-meta-replica at the server side."
This reverts commit c1aa3b2.
1 parent c62c18d commit e047929

File tree

4 files changed

+11
-144
lines changed

4 files changed

+11
-144
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private boolean tryComplete(LocateRequest req, CompletableFuture<RegionLocations
211211

212212
this.metaReplicaSelector = CatalogReplicaLoadBalanceSelectorFactory.createSelector(
213213
replicaSelectorClass, META_TABLE_NAME, conn, () -> {
214-
int numOfReplicas = CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS;
214+
int numOfReplicas = 1;
215215
try {
216216
RegionLocations metaLocations = conn.registry.getMetaRegionLocations().get(
217217
conn.connConf.getReadRpcTimeoutNs(), TimeUnit.NANOSECONDS);

hbase-client/src/main/java/org/apache/hadoop/hbase/client/CatalogReplicaLoadBalanceSelector.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
@InterfaceAudience.Private
2929
interface CatalogReplicaLoadBalanceSelector {
3030

31-
int UNINITIALIZED_NUM_OF_REPLICAS = -1;
32-
3331
/**
3432
* This method is called when input location is stale, i.e, when clients run into
3533
* org.apache.hadoop.hbase.NotServingRegionException.

hbase-client/src/main/java/org/apache/hadoop/hbase/client/CatalogReplicaLoadBalanceSimpleSelector.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public String toString() {
108108
private final TableName tableName;
109109
private final IntSupplier getNumOfReplicas;
110110
private volatile boolean isStopped = false;
111+
private final static int UNINITIALIZED_NUM_OF_REPLICAS = -1;
111112

112113
CatalogReplicaLoadBalanceSimpleSelector(TableName tableName, AsyncConnectionImpl conn,
113114
IntSupplier getNumOfReplicas) {
@@ -116,7 +117,7 @@ public String toString() {
116117
this.getNumOfReplicas = getNumOfReplicas;
117118

118119
// This numOfReplicas is going to be lazy initialized.
119-
this.numOfReplicas = CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS;
120+
this.numOfReplicas = UNINITIALIZED_NUM_OF_REPLICAS;
120121
// Start chores
121122
this.conn.getChoreService().scheduleChore(getCacheCleanupChore(this));
122123
this.conn.getChoreService().scheduleChore(getRefreshReplicaCountChore(this));
@@ -145,7 +146,7 @@ public void onError(HRegionLocation loc) {
145146
*/
146147
private int getRandomReplicaId() {
147148
int cachedNumOfReplicas = this.numOfReplicas;
148-
if (cachedNumOfReplicas == CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS) {
149+
if (cachedNumOfReplicas == UNINITIALIZED_NUM_OF_REPLICAS) {
149150
cachedNumOfReplicas = refreshCatalogReplicaCount();
150151
this.numOfReplicas = cachedNumOfReplicas;
151152
}
@@ -261,16 +262,16 @@ private void cleanupReplicaReplicaStaleCache() {
261262
private int refreshCatalogReplicaCount() {
262263
int newNumOfReplicas = this.getNumOfReplicas.getAsInt();
263264
LOG.debug("Refreshed replica count {}", newNumOfReplicas);
264-
// If the returned number of replicas is -1, it is caused by failure to fetch the
265-
// replica count. Do not update the numOfReplicas in this case.
266-
if (newNumOfReplicas == CatalogReplicaLoadBalanceSelector.UNINITIALIZED_NUM_OF_REPLICAS) {
267-
LOG.error("Failed to fetch Table {}'s region replica count", tableName);
268-
return this.numOfReplicas;
265+
if (newNumOfReplicas == 1) {
266+
LOG.warn("Table {}'s region replica count is 1, maybe a misconfiguration or failure to "
267+
+ "fetch the replica count", tableName);
269268
}
270-
271269
int cachedNumOfReplicas = this.numOfReplicas;
270+
271+
// If the returned number of replicas is 1, it is mostly caused by failure to fetch the
272+
// replica count. Do not update the numOfReplicas in this case.
272273
if ((cachedNumOfReplicas == UNINITIALIZED_NUM_OF_REPLICAS) ||
273-
(cachedNumOfReplicas != newNumOfReplicas)) {
274+
((cachedNumOfReplicas != newNumOfReplicas) && (newNumOfReplicas != 1))) {
274275
this.numOfReplicas = newNumOfReplicas;
275276
}
276277
return newNumOfReplicas;

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCatalogReplicaLoadBalanceSimpleSelector.java

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)