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

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

Conversation

ndimiduk
Copy link
Member

@ndimiduk ndimiduk commented Jan 6, 2022

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.

@ndimiduk ndimiduk 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
Member Author

ndimiduk commented Jan 6, 2022

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.

@ndimiduk ndimiduk requested a review from huaxiangsun January 6, 2022 21:38
@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.

Copy link
Member

@joshelser joshelser left a comment

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
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
Member Author

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
Member Author

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
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
Member Author

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
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
Member Author

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.

Copy link
Member Author

@ndimiduk ndimiduk left a comment

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
Member Author

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
Member Author

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
Member Author

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 ndimiduk force-pushed the 26474-tracing-connection-level-attributes-branch-2 branch from e85eba6 to b28307b Compare January 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.

Copy link
Contributor

@huaxiangsun huaxiangsun left a comment

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 <[email protected]>
@ndimiduk ndimiduk requested a review from joshelser January 12, 2022 17:16
@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 41s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
_ branch-2 Compile Tests _
+0 🆗 mvndep 0m 15s Maven dependency ordering for branch
+1 💚 mvninstall 3m 46s branch-2 passed
+1 💚 compile 5m 20s branch-2 passed
+1 💚 checkstyle 2m 0s branch-2 passed
+1 💚 spotbugs 4m 5s branch-2 passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 15s Maven dependency ordering for patch
+1 💚 mvninstall 3m 40s the patch passed
+1 💚 compile 5m 18s the patch passed
+1 💚 javac 5m 18s the patch passed
+1 💚 checkstyle 0m 24s The patch passed checkstyle in hbase-common
+1 💚 checkstyle 0m 33s hbase-client: The patch generated 0 new + 36 unchanged - 1 fixed = 36 total (was 37)
+1 💚 checkstyle 1m 6s The patch passed checkstyle in hbase-server
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 hadoopcheck 14m 5s Patch does not cause any errors with Hadoop 3.1.2 3.2.1.
+1 💚 spotbugs 5m 16s the patch passed
_ Other Tests _
+1 💚 asflicense 0m 30s The patch does not generate ASF License warnings.
58m 2s
Subsystem Report/Notes
Docker ClientAPI=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 Tests dupname asflicense javac spotbugs hadoopcheck hbaseanti checkstyle compile
uname Linux 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 tool maven
Personality dev-support/hbase-personality.sh
git revision branch-2 / de84082
Default Java AdoptOpenJDK-1.8.0_282-b08
Max. process+thread count 96 (vs. ulimit of 12500)
modules C: hbase-common hbase-client hbase-server U: .
Console output https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/console
versions git=2.17.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 37s Docker mode activated.
-0 ⚠️ yetus 0m 10s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ branch-2 Compile Tests _
+0 🆗 mvndep 0m 34s Maven dependency ordering for branch
+1 💚 mvninstall 4m 33s branch-2 passed
+1 💚 compile 2m 18s branch-2 passed
+1 💚 shadedjars 7m 31s branch has no errors when building our shaded downstream artifacts.
+1 💚 javadoc 1m 40s branch-2 passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 17s Maven dependency ordering for patch
+1 💚 mvninstall 4m 28s the patch passed
+1 💚 compile 2m 13s the patch passed
+1 💚 javac 2m 13s the patch passed
+1 💚 shadedjars 7m 30s patch has no errors when building our shaded downstream artifacts.
+1 💚 javadoc 1m 36s the patch passed
_ Other Tests _
+1 💚 unit 1m 51s hbase-common in the patch passed.
+1 💚 unit 2m 47s hbase-client in the patch passed.
+1 💚 unit 139m 16s hbase-server in the patch passed.
180m 0s
Subsystem Report/Notes
Docker ClientAPI=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 Tests javac javadoc unit shadedjars compile
uname Linux 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 tool maven
Personality dev-support/hbase-personality.sh
git revision branch-2 / de84082
Default Java AdoptOpenJDK-11.0.10+9
Test Results https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/testReport/
Max. process+thread count 3938 (vs. ulimit of 12500)
modules C: hbase-common hbase-client hbase-server U: .
Console output https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/console
versions git=2.17.1 maven=3.6.3
Powered by Apache 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

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 11s Docker mode activated.
-0 ⚠️ yetus 0m 6s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ branch-2 Compile Tests _
+0 🆗 mvndep 0m 44s Maven dependency ordering for branch
+1 💚 mvninstall 6m 8s branch-2 passed
+1 💚 compile 1m 53s branch-2 passed
+1 💚 shadedjars 7m 9s branch has no errors when building our shaded downstream artifacts.
+1 💚 javadoc 1m 25s branch-2 passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 14s Maven dependency ordering for patch
+1 💚 mvninstall 4m 2s the patch passed
+1 💚 compile 1m 56s the patch passed
+1 💚 javac 1m 56s the patch passed
+1 💚 shadedjars 7m 10s patch has no errors when building our shaded downstream artifacts.
+1 💚 javadoc 1m 24s the patch passed
_ Other Tests _
+1 💚 unit 1m 36s hbase-common in the patch passed.
+1 💚 unit 2m 52s hbase-client in the patch passed.
+1 💚 unit 222m 44s hbase-server in the patch passed.
262m 45s
Subsystem Report/Notes
Docker ClientAPI=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 Tests javac javadoc unit shadedjars compile
uname Linux 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 tool maven
Personality dev-support/hbase-personality.sh
git revision branch-2 / de84082
Default Java AdoptOpenJDK-1.8.0_282-b08
Test Results https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/testReport/
Max. process+thread count 2732 (vs. ulimit of 12500)
modules C: hbase-common hbase-client hbase-server U: .
Console output https://ci-hadoop.apache.org/job/HBase/job/HBase-PreCommit-GitHub-PR/job/PR-4014/4/console
versions git=2.17.1 maven=3.6.3
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@ndimiduk ndimiduk merged commit d4f2b66 into apache:branch-2 Jan 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 <[email protected]>
Signed-off-by: Huaxiang Sun <[email protected]>
Co-authored-by: Josh Elser <[email protected]>
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 <[email protected]>
Signed-off-by: Huaxiang Sun <[email protected]>
Co-authored-by: Josh Elser <[email protected]>
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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport This 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