-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-23561 Look up of Region in Master by encoded region name is O(n) #1193
Conversation
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The test failure reported is not an actual UT failure, somehow the jenkins process didn't terminate properly. Triggered a rebuild, just in case, planning to merge this later today if we get a green.
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Got a green, let me merge this PR. Thanks for the contribution, @mwkang ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this @mwkang It looks good. Only question is if the methods where we modify the two maps are sure to only have a single thread accessing them at at a time. I think they should be good because synchronize or locks are taken at a higher level by accessors IIRC. Might be worth a check.
@saintstack I think it looks okay. However, I am not sure only a single thread accessing them. And as you have already mentioned, If I want to synchronize two maps, I should use synchronize or locks. It was my mistake. I didn't think about it then. Should do I use synchronized or locks? |
I think the current code may have different values for the two maps. // ...
private final Object regionsMapLock = new Object();
// ...
RegionStateNode createRegionStateNode(RegionInfo regionInfo) {
synchronized (regionsMapLock) {
RegionStateNode node = regionsMap.computeIfAbsent(regionInfo.getRegionName(), key -> new RegionStateNod(regionInfo, regionInTransition));
encodedRegionsMap.putIfAbsent(node.getRegionInfo().getEncodedName(), node);
return node;
}
} Also there is a remove logic, it seems safe to use a synchronized. public void deleteRegion(final RegionInfo regionInfo) {
synchronized (regionsMapLock) {
RegionStateNode removeNode = regionsMap.remove(regionInfo.getRegionName());
encodedRegionsMap.remove(regionInfo.getEncodedName(), removeNode);
}
// ...
} |
apache#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
apache#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
apache#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
apache#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
apache#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
#1193) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
This is my first PR using github.
If something is wrong. please let me know.