Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHOENIX-7003 Harden hbase region inconsistencies check in CQSI#getAllTableRegions method #1686

Merged
merged 2 commits into from
Sep 27, 2023

Conversation

Divneet18
Copy link
Contributor

@Divneet18 Divneet18 commented Sep 21, 2023

Changing the region boundary detection conditions

@Divneet18 Divneet18 changed the title PHOENIX 7004 : Changing region boundary detection conditions PHOENIX 7003 : Changing region boundary detection conditions Sep 21, 2023
Copy link
Contributor

@stoty stoty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the commit message to conform the the Phoenix conventions, i.e.

"PHOENIX-7003 Harden hbase region inconsistencies check in CQSI#getAllTableRegions method"

@Divneet18 Divneet18 changed the title PHOENIX 7003 : Changing region boundary detection conditions PHOENIX-7003 Harden hbase region inconsistencies check in CQSI#getAllTableRegions method Sep 22, 2023
@shahrs87
Copy link
Contributor

@Divneet18 Istvan is asking to change commit message (which is here). You changed the title and that is also required.

@@ -194,7 +194,28 @@ public void testGetNextRegionStartKey() {
GlobalClientMetrics.GLOBAL_HBASE_COUNTER_METADATA_INCONSISTENCY.getMetric().reset();
when(mockHRegionInfo.getStartKey()).thenReturn(notCorruptedStartKey);
when(mockHRegionInfo.getEndKey()).thenReturn(notCorruptedNewKey);
testGetNextRegionStartKey(mockCqsi, mockRegionLocation, notCorruptedEndKey, false);
testGetNextRegionStartKey(mockCqsi, mockRegionLocation, notCorruptedEndKey, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is isCorrupted true here if both start and endkey are not corrupt and the current endkey is greater than the previous end key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the new region, the startKey in this case is 0x2999 and endKey is 0x3001. The previous regions end key is 0x3000 leading to an overlap. Hence, isCorrupted is true here. However, your confusion makes sense because the variable names were incorrect. I have updated the variable names to start with "corrupted" in all cases where isCorrupted is true and "notCorrupted" otherwise. I have pushed with new changes. Please review!

@virajjasani virajjasani self-requested a review September 24, 2023 23:17
@@ -707,7 +707,8 @@ public void clearTableRegionCache(TableName tableName) throws SQLException {
public byte[] getNextRegionStartKey(HRegionLocation regionLocation, byte[] currentKey) throws IOException {
// in order to check the overlap/inconsistencies bad region info, we have to make sure
// the current endKey always increasing(compare the previous endKey)
if (Bytes.compareTo(regionLocation.getRegion().getEndKey(), currentKey) <= 0
if ((Bytes.compareTo(regionLocation.getRegion().getStartKey(), currentKey) != 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just trying to understand what does !=0 imply? => startKey could be less than currentKey or greater than currentKey. Is that the real intention or should it specific either less than or greater than?
Also should currentKey be changed to currentEndKey to be inline with the comments and the actual intent of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever the start key of new region is not same as the end key of the previous region it will cause an overlap or a hole. Thats why when the compareTo condition is !=0 we want to throw an error.

the currentKey is the previous regions endKey being used in the getAllTableRegions method. Its being called currentKey because of how getAllTableRegions iterates over the list and compares but to avoid further confusion I have added a comment in the code mentioning currentKey=previous regions endKey

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, got it. I was thinking of the reverse condition :) Thanks for clarifying.

…SI#getAllTableRegions method) based on comments
Copy link
Contributor

@gjacoby126 gjacoby126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Thanks for the clarifications

Copy link
Contributor

@virajjasani virajjasani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@virajjasani
Copy link
Contributor

Unless there is any objections, let me merge this after 24 hr. Thank you @Divneet18!

@virajjasani virajjasani merged commit 6125f02 into apache:master Sep 27, 2023
@virajjasani
Copy link
Contributor

@Divneet18 can you please create another PR against 5.1 branch?

virajjasani pushed a commit that referenced this pull request Sep 27, 2023
@virajjasani
Copy link
Contributor

no worries, i have done the cherry-pick @Divneet18, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants