You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "yaalsn (via GitHub)" <gi...@apache.org> on 2024/05/30 06:22:15 UTC
[PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
yaalsn opened a new pull request, #22804:
URL: https://github.com/apache/pulsar/pull/22804
### Motivation
From branch-3.3, pulsar starts to use alpine as base image, but it throws exception when using snappy-java lib.
```
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.10-4b05b6fe-7374-45fc-b770-7e3728aa63de-libsnappyjava.so: Error relocating /lib/ld-linux-x86-64.so.2: unsupported relocation type 37 [in thread "pulsar-offload-write-OrderedExecutor-1-0"]
```
The reason is that alpine is musl-based OS while snappy-java lib built-in libsnappyjava.so is compiled with glibc.
In order to fix this issue, we need to re-compile the snappy-java native lib in alpine docker.
### Modifications
### Verifying this change
- [x] Make sure that the change passes the CI checks.
### Documentation
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: https://github.com/yaalsn/pulsar/pull/2
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#discussion_r1621227093
##########
docker/pulsar/Dockerfile:
##########
@@ -61,6 +61,16 @@ RUN /usr/lib/jvm/default-jvm/bin/jlink --add-modules ALL-MODULE-PATH --compress
RUN echo networkaddress.cache.ttl=1 >> /opt/jvm/conf/security/java.security
RUN echo networkaddress.cache.negative.ttl=1 >> /opt/jvm/conf/security/java.security
+## Create one stage to include snappy-java native lib
+# Fix the issue when using snappy-java in x86 arch alpine
+# See https://github.com/xerial/snappy-java/issues/181 https://github.com/xerial/snappy-java/issues/579
+# We need to ensure that the version of the native library matches the version of snappy-java imported via Maven
+FROM alpine AS snappy-java
+
+RUN apk add git alpine-sdk util-linux cmake autoconf automake libtool openjdk17 maven curl bash
+ENV JAVA_HOME=/usr
+RUN git clone https://github.com/xerial/snappy-java.git
+RUN cd snappy-java && git checkout v1.1.10.5 && make clean-native native
Review Comment:
since the version has to match `snappy.version` in the maven build, I think it would be useful to pass it as an argument to the build. for example `ARG SNAPPY_VERSION=1.1.10.5` in the Dockerfile and then passing `snappy.version` to that argument in the maven build that builds the docker image.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#discussion_r1621294472
##########
bin/pulsar:
##########
@@ -313,6 +313,9 @@ OPTS="$OPTS -Dpulsar.functions.extra.dependencies.dir=${FUNCTIONS_EXTRA_DEPS_DIR
OPTS="$OPTS -Dpulsar.functions.instance.classpath=${PULSAR_CLASSPATH}"
OPTS="$OPTS -Dpulsar.functions.log.conf=${FUNCTIONS_LOG_CONF}"
+# Enable snappy-java to use system lib
+OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"
+
Review Comment:
A cleaner solution would be to add a feature to `bin/pulsar` so that you can pass an environment variable to specify a script that gets included sourced if a specific environment variable is set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141852271
> One problem is that building snappy may take a lot of time.
>
> I haven't tested it yet.
It doesn't take long to build.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141369871
> We don't need to add that in the OPTS by default. We can add a comment to say if you need snappy, add this `-Dorg.xerial.snappy.use.systemlib=true` to the PULSAR_EXTRA_OPTS
I don't think that this is a good idea to have more configuration options to tweak. It's better to handle this in the Dockerfile building phase as I suggested by simply appending `OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"` to the `conf/bkenv.sh` file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#discussion_r1621283770
##########
bin/pulsar:
##########
@@ -313,6 +313,9 @@ OPTS="$OPTS -Dpulsar.functions.extra.dependencies.dir=${FUNCTIONS_EXTRA_DEPS_DIR
OPTS="$OPTS -Dpulsar.functions.instance.classpath=${PULSAR_CLASSPATH}"
OPTS="$OPTS -Dpulsar.functions.log.conf=${FUNCTIONS_LOG_CONF}"
+# Enable snappy-java to use system lib
+OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"
+
Review Comment:
I don't think that this should be done for the default `bin/pulsar` script. There should be another way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "zymap (via GitHub)" <gi...@apache.org>.
zymap commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141214353
> I don't think that this should be done for the default bin/pulsar script. There should be another way.
We don't need to add that in the OPTS by default. We can add a comment to say if you need snappy, add this `-Dorg.xerial.snappy.use.systemlib=true` to the PULSAR_EXTRA_OPTS
@yaalsn
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "yaalsn (via GitHub)" <gi...@apache.org>.
yaalsn commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141264617
> We don't need to add that in the OPTS by default. We can add a comment to say if you need snappy, add this -Dorg.xerial.snappy.use.systemlib=true to the PULSAR_EXTRA_OPTS
Nice! This way is better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141331813
@lhotari @zymap PTAL
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2139332103
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/22804?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 73.22%. Comparing base [(`bbc6224`)](https://app.codecov.io/gh/apache/pulsar/commit/bbc62245c5ddba1de4b1e7cee4ab49334bc36277?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`dff4565`)](https://app.codecov.io/gh/apache/pulsar/commit/dff4565b9734b8da1b8500fe0a5e0454aa12fdd8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 319 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/pulsar/pull/22804?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #22804 +/- ##
============================================
- Coverage 73.57% 73.22% -0.35%
+ Complexity 32624 32617 -7
============================================
Files 1877 1890 +13
Lines 139502 141644 +2142
Branches 15299 15541 +242
============================================
+ Hits 102638 103721 +1083
- Misses 28908 29917 +1009
- Partials 7956 8006 +50
```
| [Flag](https://app.codecov.io/gh/apache/pulsar/pull/22804/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [inttests](https://app.codecov.io/gh/apache/pulsar/pull/22804/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.37% <ø> (+2.79%)` | :arrow_up: |
| [systests](https://app.codecov.io/gh/apache/pulsar/pull/22804/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `24.75% <ø> (+0.43%)` | :arrow_up: |
| [unittests](https://app.codecov.io/gh/apache/pulsar/pull/22804/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.22% <ø> (-0.62%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
[see 364 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/22804/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "nodece (via GitHub)" <gi...@apache.org>.
nodece commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141827500
One problem is that building snappy may take a lot of time.
I haven't tested it yet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#discussion_r1621291935
##########
bin/pulsar:
##########
@@ -313,6 +313,9 @@ OPTS="$OPTS -Dpulsar.functions.extra.dependencies.dir=${FUNCTIONS_EXTRA_DEPS_DIR
OPTS="$OPTS -Dpulsar.functions.instance.classpath=${PULSAR_CLASSPATH}"
OPTS="$OPTS -Dpulsar.functions.log.conf=${FUNCTIONS_LOG_CONF}"
+# Enable snappy-java to use system lib
+OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"
+
Review Comment:
One possible solution is to append `OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"` to `conf/bkenv.sh` file while building the docker image. `conf/bkenv.sh` will get included for all executions of `bin/pulsar`:
https://github.com/apache/pulsar/blob/60ebab4ca6f8a45e72d1d61e29b433dde06da192/bin/pulsar#L109-L113
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2143851711
@lhotari PTAL
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "zymap (via GitHub)" <gi...@apache.org>.
zymap commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141613061
both ok to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#discussion_r1621291935
##########
bin/pulsar:
##########
@@ -313,6 +313,9 @@ OPTS="$OPTS -Dpulsar.functions.extra.dependencies.dir=${FUNCTIONS_EXTRA_DEPS_DIR
OPTS="$OPTS -Dpulsar.functions.instance.classpath=${PULSAR_CLASSPATH}"
OPTS="$OPTS -Dpulsar.functions.log.conf=${FUNCTIONS_LOG_CONF}"
+# Enable snappy-java to use system lib
+OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"
+
Review Comment:
One possible solution is to append `OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"` to `conf/bkenv.sh` file while building the docker image. `conf/bkenv.sh` will get included for all executions of `bin/pulsar`:
https://github.com/apache/pulsar/blob/60ebab4ca6f8a45e72d1d61e29b433dde06da192/bin/pulsar#L109-L119
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc closed pull request #22804: [fix][ci] Fix snappy-java native lib fails to load in x86 alpine
URL: https://github.com/apache/pulsar/pull/22804
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2138896029
I verified this PR and it works fine.
```
docker run -it \
-e PULSAR_STANDALONE_USE_ZOOKEEPER=1 \
-e PULSAR_EXTRA_OPTS="-Dzookeeper.snapshot.compression.method=snappy" \
--platform=linux/amd64 \
czcoder/pulsar:3.3.0-66baa8d \
bin/pulsar standalone
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#discussion_r1621232251
##########
docker/pulsar/Dockerfile:
##########
@@ -61,6 +61,16 @@ RUN /usr/lib/jvm/default-jvm/bin/jlink --add-modules ALL-MODULE-PATH --compress
RUN echo networkaddress.cache.ttl=1 >> /opt/jvm/conf/security/java.security
RUN echo networkaddress.cache.negative.ttl=1 >> /opt/jvm/conf/security/java.security
+## Create one stage to include snappy-java native lib
+# Fix the issue when using snappy-java in x86 arch alpine
+# See https://github.com/xerial/snappy-java/issues/181 https://github.com/xerial/snappy-java/issues/579
+# We need to ensure that the version of the native library matches the version of snappy-java imported via Maven
+FROM alpine AS snappy-java
+
+RUN apk add git alpine-sdk util-linux cmake autoconf automake libtool openjdk17 maven curl bash
+ENV JAVA_HOME=/usr
+RUN git clone https://github.com/xerial/snappy-java.git
+RUN cd snappy-java && git checkout v1.1.10.5 && make clean-native native
Review Comment:
instead of using `git clone`, I think it's better to use the `.tar.gz` provided by GitHub. Something like
```
ARG SNAPPY_VERSION=1.1.10.5
...
RUN curl -Ls https://github.com/xerial/snappy-java/archive/refs/tags/v$SNAPPY_VERSION.tar.gz | tar zxf - && cd snappy-java-$SNAPPY_VERSION && make clean-native native
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc merged PR #22804:
URL: https://github.com/apache/pulsar/pull/22804
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][ci] Fix snappy-java native lib fails to load in x86 alpine [pulsar]
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #22804:
URL: https://github.com/apache/pulsar/pull/22804#issuecomment-2141558799
> I don't think that this is a good idea to have more configuration options to tweak. It's better to handle this in the Dockerfile building phase as I suggested by simply appending `OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"` to the `/pulsar/conf/bkenv.sh` file.
I also prefer this solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org