Skip to content

Backport "HBASE-26474 Implement connection-level attributes" to branch-2 - #4014

Merged
ndimiduk merged 4 commits into
apache:branch-2from
ndimiduk:26474-tracing-connection-level-attributes-branch-2
Jan 18, 2022
Merged

Backport "HBASE-26474 Implement connection-level attributes" to branch-2#4014
ndimiduk merged 4 commits into
apache:branch-2from
ndimiduk:26474-tracing-connection-level-attributes-branch-2

Conversation

@ndimiduk

Copy link
Copy Markdown
Member

Add support for db.system, db.connection_string, db.user.

This is a non-trivial backport of #3952 to branch-2. It's non-trivial because it implements these tracing features on the non-async implementation of HRegionLocator. Please take a look at those changed with a critical reviewer's eye. A diff of the diffs might be useful for reviewers... I don't now if GitHub can produce such a thing.

@ndimidukndimiduk added the backport This PR is a back port of some issue or issues already committed to master label Jan 6, 2022
@ndimiduk

Copy link
Copy Markdown
MemberAuthor

reviewers: please notice this change to internal behavior of caching region locations in HRegionLocator#listRegionLocations(). I believe that the contents of the cache are identical before and after this change, but how the cache is populated is slightly different now.

Previously, this method returned a List<RegionLocations>. In that implementation, each entry in the list represented a Result object processed by the Visitor. These entries were then presented to the connection for caching one-by-one. The logic used to merge old and new cache entries was also used to merge all of these new results.

I think the one-to-one mapping is an unnecessary preservation of arbitrary physical topology of the scan of the meta region. The change here has listRegionLocations() perform this consolidation before returning results. Performing the consolidate action here allows the HRegionLocator to behave in a manner that is similar to AsyncRegionLocator and even reuse some of its code.

This new implementation may also make region caching slightly (negligibly) faster because the logic for cache entry management is quite complex, while the logic for naively combining multiple RegionLocations objects into a single instance is much simpler.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@joshelserjoshelser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Barring the comments from Huaxiang, looks pretty reasonable to me. A couple questions on type-hierarchy and package visibility, but overall it looks like a very nice cleanup (around a tough-to-reason part of HBase code).

return Optional.ofNullable(location)
.map(HRegionLocation::getRegion)
.map(RegionInfo::getRegionNameAsString)
.map(Collections::singletonList)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will net an immutable list whereas Arrays.asList() (as previously used down below) was returning a mutable list. Hopefully we would not be altering this List, but noting a change in implementation to make sure it was intentional.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Noted. I had not considered mutability of the previous implementation. Consider this change to immutability a happy side-effect. At least on the master PR, this appears to have introduced no issues. Perhaps this is cause for some of the test failures I seem to have caused in the branch-2 backport. Let me investigate.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

No test failures after reverting the erroneous changes pointed out by Huaxiang, so I'll take that as acceptability of the immutable collection. Shout if that's not okay by you.

* All {@link Span}s involving {@code conn} should include these attributes.
* @see #buildConnectionAttributesMatcher(AsyncConnectionImpl)
*/
public static Matcher<SpanData> buildConnectionAttributesMatcher(ConnectionImplementation conn) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this usage why ConnectionImplementation was made public? I remember when ConnectionImplementation was made package-private back in HBase 1.x. Do you think this is sufficient to make it public again? (or maybe I've missed the real reason)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yes, Both ConnectionImplementation and AsyncConnectionImpl became public classes in order to facilitate their introspection for tracing. Not for this test class, but for their use in the Builders. They remain IA.Private, so I'm not concerned about leaking to user applications. I'm not familiar with the conversation that lead to them being package private; do you have context or specific concerns that can enlighten me?

* Construct {@link Span} instances involving data tables.
*/
@InterfaceAudience.Private
public class TableSpanBuilder implements Supplier<Span> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pretty similar to ConnectionSpanBuilder. Should they share a parent class or some common utility methods?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

An earlier version of this code made use of inheritance for these builders and the template gymnastics required were awful. Following Duo's suggestion, I undid that implementation in favor of this mix-in style approach with reused utility methods. Lots of code that was DRY in the inheritance version becomes repeated in this mix-in style. For me, I think this repeated code is worth the hassle, because it'll be easier to maintain than the complex hierarchy with esoteric template definitions.

All that said, if you see specific segments that could be extracted into utility methods, I'm happy to make the improvements.

@ndimidukndimiduk left a comment

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Thank you @huaxiangsun for pointing out the error of my ways. Undoing those changes to region locations, this backport becomes boring. Let's see if the pre-commit tests agree with me.

Thank you @joshelser for your comments. I wish I'd had your attention on the master PR. I may need to put up an addendum to address one or two of your concerns.

return Optional.ofNullable(location)
.map(HRegionLocation::getRegion)
.map(RegionInfo::getRegionNameAsString)
.map(Collections::singletonList)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Noted. I had not considered mutability of the previous implementation. Consider this change to immutability a happy side-effect. At least on the master PR, this appears to have introduced no issues. Perhaps this is cause for some of the test failures I seem to have caused in the branch-2 backport. Let me investigate.

* Construct {@link Span} instances involving data tables.
*/
@InterfaceAudience.Private
public class TableSpanBuilder implements Supplier<Span> {

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

An earlier version of this code made use of inheritance for these builders and the template gymnastics required were awful. Following Duo's suggestion, I undid that implementation in favor of this mix-in style approach with reused utility methods. Lots of code that was DRY in the inheritance version becomes repeated in this mix-in style. For me, I think this repeated code is worth the hassle, because it'll be easier to maintain than the complex hierarchy with esoteric template definitions.

All that said, if you see specific segments that could be extracted into utility methods, I'm happy to make the improvements.

* All {@link Span}s involving {@code conn} should include these attributes.
* @see #buildConnectionAttributesMatcher(AsyncConnectionImpl)
*/
public static Matcher<SpanData> buildConnectionAttributesMatcher(ConnectionImplementation conn) {

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yes, Both ConnectionImplementation and AsyncConnectionImpl became public classes in order to facilitate their introspection for tracing. Not for this test class, but for their use in the Builders. They remain IA.Private, so I'm not concerned about leaking to user applications. I'm not familiar with the conversation that lead to them being package private; do you have context or specific concerns that can enlighten me?

@ndimiduk
ndimidukforce-pushed the 26474-tracing-connection-level-attributes-branch-2 branch from e85eba6 to b28307bCompareJanuary 12, 2022 02:47
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@huaxiangsunhuaxiangsun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me.

Co-authored-by: Josh Elser <josh.elser@gmail.com>
@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 41sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 1sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ branch-2 Compile Tests _
+0 🆗mvndep0m 15sMaven dependency ordering for branch
+1 💚mvninstall3m 46sbranch-2 passed
+1 💚compile5m 20sbranch-2 passed
+1 💚checkstyle2m 0sbranch-2 passed
+1 💚spotbugs4m 5sbranch-2 passed
_ Patch Compile Tests _
+0 🆗mvndep0m 15sMaven dependency ordering for patch
+1 💚mvninstall3m 40sthe patch passed
+1 💚compile5m 18sthe patch passed
+1 💚javac5m 18sthe patch passed
+1 💚checkstyle0m 24sThe patch passed checkstyle in hbase-common
+1 💚checkstyle0m 33shbase-client: The patch generated 0 new + 36 unchanged - 1 fixed = 36 total (was 37)
+1 💚checkstyle1m 6sThe patch passed checkstyle in hbase-server
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚hadoopcheck14m 5sPatch does not cause any errors with Hadoop 3.1.2 3.2.1.
+1 💚spotbugs5m 16sthe patch passed
_ Other Tests _
+1 💚asflicense0m 30sThe patch does not generate ASF License warnings.
58m 2s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#4014
Optional Testsdupname asflicense javac spotbugs hadoopcheck hbaseanti checkstyle compile
unameLinux cd55166f9e61 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionbranch-2 / de84082
Default JavaAdoptOpenJDK-1.8.0_282-b08
Max. process+thread count96 (vs. ulimit of 12500)
modulesC: hbase-common hbase-client hbase-server U: .
Console outputhttps://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/console
versionsgit=2.17.1 maven=3.6.3 spotbugs=4.2.2
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 37sDocker mode activated.
-0 ⚠️yetus0m 10sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ branch-2 Compile Tests _
+0 🆗mvndep0m 34sMaven dependency ordering for branch
+1 💚mvninstall4m 33sbranch-2 passed
+1 💚compile2m 18sbranch-2 passed
+1 💚shadedjars7m 31sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc1m 40sbranch-2 passed
_ Patch Compile Tests _
+0 🆗mvndep0m 17sMaven dependency ordering for patch
+1 💚mvninstall4m 28sthe patch passed
+1 💚compile2m 13sthe patch passed
+1 💚javac2m 13sthe patch passed
+1 💚shadedjars7m 30spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc1m 36sthe patch passed
_ Other Tests _
+1 💚unit1m 51shbase-common in the patch passed.
+1 💚unit2m 47shbase-client in the patch passed.
+1 💚unit139m 16shbase-server in the patch passed.
180m 0s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/artifact/yetus-jdk11-hadoop3-check/output/Dockerfile
GITHUB PR#4014
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 9d6ac1c9518c 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionbranch-2 / de84082
Default JavaAdoptOpenJDK-11.0.10+9
Test Resultshttps://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/testReport/
Max. process+thread count3938 (vs. ulimit of 12500)
modulesC: hbase-common hbase-client hbase-server U: .
Console outputhttps://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/console
versionsgit=2.17.1 maven=3.6.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

ndimiduk added a commit to ndimiduk/hbase that referenced this pull request Jan 12, 2022
Addressing additional comments raised in branch-2 backport PR apache#4014
@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 11sDocker mode activated.
-0 ⚠️yetus0m 6sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ branch-2 Compile Tests _
+0 🆗mvndep0m 44sMaven dependency ordering for branch
+1 💚mvninstall6m 8sbranch-2 passed
+1 💚compile1m 53sbranch-2 passed
+1 💚shadedjars7m 9sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc1m 25sbranch-2 passed
_ Patch Compile Tests _
+0 🆗mvndep0m 14sMaven dependency ordering for patch
+1 💚mvninstall4m 2sthe patch passed
+1 💚compile1m 56sthe patch passed
+1 💚javac1m 56sthe patch passed
+1 💚shadedjars7m 10spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc1m 24sthe patch passed
_ Other Tests _
+1 💚unit1m 36shbase-common in the patch passed.
+1 💚unit2m 52shbase-client in the patch passed.
+1 💚unit222m 44shbase-server in the patch passed.
262m 45s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/artifact/yetus-jdk8-hadoop2-check/output/Dockerfile
GITHUB PR#4014
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 0de15209a59c 4.15.0-142-generic #146-Ubuntu SMP Tue Apr 13 01:11:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionbranch-2 / de84082
Default JavaAdoptOpenJDK-1.8.0_282-b08
Test Resultshttps://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/testReport/
Max. process+thread count2732 (vs. ulimit of 12500)
modulesC: hbase-common hbase-client hbase-server U: .
Console outputhttps://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/console
versionsgit=2.17.1 maven=3.6.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@ndimiduk
ndimiduk merged commit d4f2b66 into apache:branch-2Jan 18, 2022
@ndimiduk
ndimiduk deleted the 26474-tracing-connection-level-attributes-branch-2 branch January 18, 2022 20:29
ndimiduk added a commit to ndimiduk/hbase that referenced this pull request Jan 18, 2022
Add support for `db.system`, `db.connection_string`, `db.user`.
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Huaxiang Sun <huaxiangsun@apache.org>
Co-authored-by: Josh Elser <josh.elser@gmail.com>
ndimiduk added a commit that referenced this pull request Jan 19, 2022
Add support for `db.system`, `db.connection_string`, `db.user`.
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Huaxiang Sun <huaxiangsun@apache.org>
Co-authored-by: Josh Elser <josh.elser@gmail.com>
ndimiduk added a commit that referenced this pull request Jan 24, 2022
Addressing additional comments raised in branch-2 backport PR #4014
ndimiduk added a commit to ndimiduk/hbase that referenced this pull request Jan 24, 2022
Addressing additional comments raised in branch-2 backport PR apache#4014
ndimiduk added a commit to ndimiduk/hbase that referenced this pull request Jan 24, 2022
Addressing additional comments raised in branch-2 backport PR apache#4014
ndimiduk added a commit that referenced this pull request Jan 24, 2022
Addressing additional comments raised in branch-2 backport PR #4014
ndimiduk added a commit that referenced this pull request Jan 24, 2022
Addressing additional comments raised in branch-2 backport PR #4014
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backportThis PR is a back port of some issue or issues already committed to master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ndimiduk@Apache-HBase@joshelser@huaxiangsun