guluo2016 commented on code in PR #7629:
URL: https://github.com/apache/hbase/pull/7629#discussion_r2699113829
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/RegionReplicaReplicationEndpoint.java:
##########
@@ -441,7 +441,8 @@ public void append(TableName tableName, byte[]
encodedRegionName, byte[] row,
// keep going to the cache, we will not learn of the replicas and
their locations after
// they come online.
if (useCache && locations.size() == 1) {
- if (tableDescriptors.get(tableName).getRegionReplication() > 1 &&
retries <= 3) {
+ TableDescriptor td = tableDescriptors.get(tableName);
+ if (td != null && td.getRegionReplication() > 1 && retries <= 3) {
Review Comment:
I noticed through idea's smart suggestions that `retries <= 3` seems is
unnecessary.
<img width="1134" height="109" alt="Image"
src="https://github.com/user-attachments/assets/b5056009-b54d-49b8-b2c7-1ce3ced37587"
/>
And I analyzed it and it's true
After removing it, there are 3 main cases, and none lead to an infinite loop:
- case 1
First loop: `useCache && locations.size() == 1` && `RegionReplication > 1`
is true.
Set useCache = false and continue.
Second loop: The logic will proceed and eventually return or break.
- case2
First loop: useCache && locations.size() == 1 is true but RegionReplication
> 1 is false.
Go to subsequent logic.
If `!Bytes.equals(primaryLocation.getRegionInfo().getEncodedNameAsBytes(),
encodedRegionName)` is false: break (loop ends).
If `!Bytes.equals(primaryLocation.getRegionInfo().getEncodedNameAsBytes(),
encodedRegionName)` is true and useCache is true: set useCache = false and
continue. Second loop will then return or break.
- case3
First loop: useCache && locations.size() == 1 is false.
Go to subsequent logic.
If useCache is alread false: return or break.
If useCache is true : similar to case 2, it will either break or retry once
(setting useCache=false), then finish.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]