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

[improve][test] Remove conscrypt exception stacktrace in Apple silicon #18359

Merged
merged 5 commits into from
Nov 19, 2022
Merged

[improve][test] Remove conscrypt exception stacktrace in Apple silicon #18359

merged 5 commits into from
Nov 19, 2022

Conversation

yaalsn
Copy link
Contributor

@yaalsn yaalsn commented Nov 7, 2022

Motivation

When running tests in Macos Apple silicon, there will be a long stacktrace like this

Caused by: java.lang.UnsatisfiedLinkError: no conscrypt_openjdk_jni-osx-aarch_64 in java.library.path: /Users/yaalsn/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429) ~[?:?]
	at java.lang.Runtime.loadLibrary0(Runtime.java:818) ~[?:?]
	at java.lang.System.loadLibrary(System.java:1989) ~[?:?]
	at org.conscrypt.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:54) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.conscrypt.NativeLibraryLoader$1.run(NativeLibraryLoader.java:297) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader$1.run(NativeLibraryLoader.java:289) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at java.security.AccessController.doPrivileged(AccessController.java:318) ~[?:?]
	at org.conscrypt.NativeLibraryLoader.loadLibraryFromHelperClassloader(NativeLibraryLoader.java:289) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:262) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader.load(NativeLibraryLoader.java:162) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:106) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:50) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeCrypto.<clinit>(NativeCrypto.java:64) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.Conscrypt.checkAvailability(Conscrypt.java:119) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	... 41 more

...

There's no osx aarch_64 conscrypt, so we can filter this stacktrace by catching java.lang.UnsatisfiedLinkError.

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: https://github.com/yaalsn/pulsar/pull/16

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 7, 2022
@@ -124,7 +124,12 @@ private static Provider loadConscryptProvider() {
conscryptClazz = Class.forName("org.conscrypt.Conscrypt");
conscryptClazz.getMethod("checkAvailability").invoke(null);
} catch (Throwable e) {
log.warn("Conscrypt isn't available. Using JDK default security provider.", e);
if (e.getCause() != null && e.getCause().getClass().getName().equals("java.lang.UnsatisfiedLinkError")) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we use debug instead of warn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better to use level warn because it is a exception — not a If - else or something needs to record. This warn means conscrypt is not supported which needs to remind.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to avoid the too-long message, I suggest you just output the message and then add a debug log to print the stack trace.

…rityUtility.java

Co-authored-by: Cong Zhao <zhaocong@apache.org>
@codelipenghui codelipenghui added this to the 2.12.0 milestone Nov 16, 2022
@codelipenghui codelipenghui added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages type/flaky-tests area/test and removed type/flaky-tests labels Nov 16, 2022
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codecov-commenter
Copy link

codecov-commenter commented Nov 16, 2022

Codecov Report

Merging #18359 (d96b604) into master (67d9d63) will increase coverage by 7.62%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18359      +/-   ##
============================================
+ Coverage     40.29%   47.91%   +7.62%     
- Complexity     8685     9352     +667     
============================================
  Files           687      613      -74     
  Lines         67441    58391    -9050     
  Branches       7225     6087    -1138     
============================================
+ Hits          27175    27979     +804     
+ Misses        37257    27386    -9871     
- Partials       3009     3026      +17     
Flag Coverage Δ
unittests 47.91% <ø> (+7.62%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../apache/pulsar/broker/loadbalance/LoadManager.java 61.11% <0.00%> (-16.67%) ⬇️
...tent/NonPersistentDispatcherMultipleConsumers.java 40.74% <0.00%> (-12.35%) ⬇️
...apache/pulsar/broker/service/TopicListService.java 42.62% <0.00%> (-12.30%) ⬇️
.../pulsar/broker/service/SharedConsumerAssignor.java 68.51% <0.00%> (-9.26%) ⬇️
...pulsar/broker/service/PulsarCommandSenderImpl.java 71.72% <0.00%> (-6.29%) ⬇️
...oker/service/schema/SchemaRegistryServiceImpl.java 60.66% <0.00%> (-4.21%) ⬇️
...tent/PersistentDispatcherSingleActiveConsumer.java 55.17% <0.00%> (-4.08%) ⬇️
.../pulsar/broker/service/BrokerServiceException.java 42.59% <0.00%> (-3.71%) ⬇️
...ker/resourcegroup/ResourceGroupConfigListener.java 64.38% <0.00%> (-2.74%) ⬇️
...sar/broker/service/schema/SchemaRegistryStats.java 72.50% <0.00%> (-2.50%) ⬇️
... and 275 more

@nodece nodece requested a review from tisonkun November 16, 2022 08:40
Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

LGTM. One code quality suggestion inline.

@@ -124,7 +124,12 @@ private static Provider loadConscryptProvider() {
conscryptClazz = Class.forName("org.conscrypt.Conscrypt");
conscryptClazz.getMethod("checkAvailability").invoke(null);
} catch (Throwable e) {
log.warn("Conscrypt isn't available. Using JDK default security provider.", e);
if (e.getCause() instanceof UnsatisfiedLinkError) {
Copy link
Member

Choose a reason for hiding this comment

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

@codelipenghui @nodece Do we have an exception util like Flink's findThrowable? I'm afraid that the error may be changed to differ wrap level.

Copy link
Member

Choose a reason for hiding this comment

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

No.

@yaalsn
Copy link
Contributor Author

yaalsn commented Nov 16, 2022

/pulsarbot run-failure-checks

@Technoboy- Technoboy- merged commit 73ea9ff into apache:master Nov 19, 2022
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants