Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ jobs:
java-version: ${{ matrix.java-version }}
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
native-image-job-reports: 'true'
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-${{ github.sha }}
restore-keys: |
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-
# TODO Remove this workaround after. The graalvm native image built with windows server is missing some GRMs for testcontainers
- name: Run test with GraalVM CE
if: matrix.os == 'windows-2025'
run: ./mvnw -PgenerateMetadata -e -T 1C clean test
run: ./mvnw -PgenerateMetadata -e -T 1C clean verify
- name: Run nativeTest with GraalVM CE for ${{ matrix.java-version }}
if: matrix.os == 'ubuntu-latest'
run: ./mvnw -PnativeTestInShardingSphere -e clean test
run: ./mvnw -PnativeTestInShardingSphere -e "-DjvmArgs=-XX:MaxRAMPercentage=70.0" clean verify
16 changes: 14 additions & 2 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,18 @@ jobs:
with:
distribution: 'temurin'
java-version: 11
cache: 'maven'
- uses: docker/login-action@v3
with:
registry: ${{ env.HUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-${{ github.sha }}
restore-keys: |
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-
- name: Push Docker Image by arm64 or x64
run: |
./mvnw -am -pl distribution/proxy-native -T1C "-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.sha }} "-DskipTests" clean package
Expand All @@ -158,12 +164,18 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- uses: docker/login-action@v3
with:
registry: ${{ env.HUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-${{ github.sha }}
restore-keys: |
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-
- name: Push Docker Image
run: |
./mvnw -am -pl distribution/agent -Prelease,default-dep,docker.buildx.push -B -T1C -DskipTests -Dagent.image.repository=${{ env.AGENT }} -Dagent.image.tag=${{ github.sha }} clean package
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/nightly-ci-dynamic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,26 @@ jobs:
os: ${{ fromJson(github.event.inputs.os) }}
steps:
- uses: actions/checkout@v4
- name: Setup Rancher Desktop without GUI on Windows Server
if: matrix.os == 'windows-2025'
run: |
./test/native/src/test/resources/test-native/ps1/uninstall-docker-engine-for-wcow.ps1
winget install --id jazzdelightsme.WingetPathUpdater --source winget
winget install --id SUSE.RancherDesktop --source winget --skip-dependencies
rdctl start --application.start-in-background --container-engine.name=moby --kubernetes.enabled=false
./test/native/src/test/resources/test-native/ps1/wait-for-rancher-desktop-backend.ps1
- uses: graalvm/setup-graalvm@v1
with:
java-version: '24.0.2'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
native-image-job-reports: 'true'
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-${{ github.sha }}
restore-keys: |
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-
- name: Run nativeTest with GraalVM CE
run: ./mvnw -PnativeTestInShardingSphere -e clean test
run: ./mvnw -PnativeTestInShardingSphere -e "-DjvmArgs=-XX:MaxRAMPercentage=70.0" clean verify
12 changes: 9 additions & 3 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,18 @@ jobs:
java-version: '24.0.2'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
native-image-job-reports: 'true'
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-${{ github.sha }}
restore-keys: |
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-
# TODO Remove this workaround after. The graalvm native image built with windows server is missing some GRMs for testcontainers
- name: Run test with GraalVM CE
if: matrix.os == 'windows-2025'
run: ./mvnw -PgenerateMetadata -e -T 1C clean test
run: ./mvnw -PgenerateMetadata -e -T 1C clean verify
- name: Run nativeTest with GraalVM CE
if: matrix.os == 'ubuntu-latest'
run: ./mvnw -PnativeTestInShardingSphere -e clean test
run: ./mvnw -PnativeTestInShardingSphere -e "-DjvmArgs=-XX:MaxRAMPercentage=70.0" clean verify
3 changes: 2 additions & 1 deletion distribution/proxy-native/Dockerfile-linux-mostly
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#

FROM ghcr.io/graalvm/native-image-community:24.0.2 AS nativebuild
ENV NATIVE_IMAGE_OPTIONS="--static-nolibc"
WORKDIR /build
COPY ./ .
RUN --mount=type=cache,target=/root/.m2 ./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+AddAllCharsets,-H:+IncludeAllLocales,--static-nolibc" clean package
RUN --mount=type=cache,target=/root/.m2 ./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" clean package

FROM gcr.io/distroless/base-debian12:latest
LABEL org.opencontainers.image.authors="ShardingSphere [email protected]"
Expand Down
3 changes: 2 additions & 1 deletion distribution/proxy-native/Dockerfile-linux-static
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#

FROM ghcr.io/graalvm/native-image-community:24.0.2-muslib AS nativebuild
ENV NATIVE_IMAGE_OPTIONS="--static,--libc=musl"
WORKDIR /build
COPY ./ .
RUN --mount=type=cache,target=/root/.m2 ./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+AddAllCharsets,-H:+IncludeAllLocales,--static,--libc=musl" clean package
RUN --mount=type=cache,target=/root/.m2 ./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" clean package

FROM scratch
LABEL org.opencontainers.image.authors="ShardingSphere [email protected]"
Expand Down
1 change: 1 addition & 0 deletions distribution/proxy-native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<mainClass>org.apache.shardingsphere.proxy.Bootstrap</mainClass>
<imageName>${proxy.native.image.filename}</imageName>
<buildArgs>
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
<buildArg>-H:+AddAllCharsets</buildArg>
<buildArg>-H:+IncludeAllLocales</buildArg>
</buildArgs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ java.beans.Introspector was unintentionally initialized at build time. To see wh
<extensions>true</extensions>
<configuration>
<buildArgs>
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
<buildArg>-H:+AddAllCharsets</buildArg>
<buildArg>-H:+IncludeAllLocales</buildArg>
</buildArgs>
Expand Down Expand Up @@ -102,10 +103,12 @@ dependencies {
graalvmNative {
binaries {
main {
buildArgs.add('-H:+UnlockExperimentalVMOptions')
buildArgs.add('-H:+AddAllCharsets')
buildArgs.add('-H:+IncludeAllLocales')
}
test {
buildArgs.add('-H:+UnlockExperimentalVMOptions')
buildArgs.add('-H:+AddAllCharsets')
buildArgs.add('-H:+IncludeAllLocales')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ and the documentation of GraalVM Native Build Tools shall prevail.
<extensions>true</extensions>
<configuration>
<buildArgs>
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
<buildArg>-H:+AddAllCharsets</buildArg>
<buildArg>-H:+IncludeAllLocales</buildArg>
</buildArgs>
Expand Down Expand Up @@ -105,10 +106,12 @@ dependencies {
graalvmNative {
binaries {
main {
buildArgs.add('-H:+UnlockExperimentalVMOptions')
buildArgs.add('-H:+AddAllCharsets')
buildArgs.add('-H:+IncludeAllLocales')
}
test {
buildArgs.add('-H:+UnlockExperimentalVMOptions')
buildArgs.add('-H:+AddAllCharsets')
buildArgs.add('-H:+IncludeAllLocales')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,40 @@ class SolutionTest {
`org.apache.shardingsphere.test.natived.proxy.transactions.base.SeataTest` 已被禁用,
因为在 Github Actions Runner 执行此单元测试将导致其他单元测试出现 JDBC 连接泄露。
### `CodeCachePoolMXBean` 限制
当前执行 `./mvnw -PnativeTestInShardingSphere -e -T 1C clean verify` 将涉及到针对 `com.oracle.svm.core.code.CodeCachePoolMXBean` 的警告日志,
```shell
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access

com.oracle.svm.core.code.CodeCachePoolMXBean$CodeAndDataPool.getConstructors()

without it being registered for runtime reflection. Add com.oracle.svm.core.code.CodeCachePoolMXBean$CodeAndDataPool.getConstructors() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getConstructors(DynamicHub.java:1128)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.findConstructors(MBeanIntrospector.java:459)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getClassMBeanInfo(MBeanIntrospector.java:430)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getMBeanInfo(MBeanIntrospector.java:389)
[email protected]/com.sun.jmx.mbeanserver.MBeanSupport.<init>(MBeanSupport.java:137)
[email protected]/com.sun.jmx.mbeanserver.MXBeanSupport.<init>(MXBeanSupport.java:66)
[email protected]/javax.management.StandardMBean.construct(StandardMBean.java:174)
[email protected]/javax.management.StandardMBean.<init>(StandardMBean.java:268)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access

com.oracle.svm.core.code.CodeCachePoolMXBean$NativeMetadataPool.getConstructors()

without it being registered for runtime reflection. Add com.oracle.svm.core.code.CodeCachePoolMXBean$NativeMetadataPool.getConstructors() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getConstructors(DynamicHub.java:1128)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.findConstructors(MBeanIntrospector.java:459)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getClassMBeanInfo(MBeanIntrospector.java:430)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getMBeanInfo(MBeanIntrospector.java:389)
[email protected]/com.sun.jmx.mbeanserver.MBeanSupport.<init>(MBeanSupport.java:137)
[email protected]/com.sun.jmx.mbeanserver.MXBeanSupport.<init>(MXBeanSupport.java:66)
[email protected]/javax.management.StandardMBean.construct(StandardMBean.java:174)
[email protected]/javax.management.StandardMBean.<init>(StandardMBean.java:268)
```
相关警告在 `GraalVM CE For JDK 24.0.2` 上无法避免。
因为 `com.oracle.svm.core.code.CodeCachePoolMXBean` 的无参构造函数通过 Java 类 `org.graalvm.nativeimage.Platform.HOSTED_ONLY` 被标记为无论实际的 Platform 是什么,
仅在 Native Image 生成期间可见,且无法在 Runtime 使用的元素。
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,41 @@ the unit test of `org.apache.shardingsphere.test.natived.jdbc.modes.cluster.Etcd
`org.apache.shardingsphere.test.natived.proxy.transactions.base.SeataTest` has been disabled
because executing this unit test in Github Actions Runner will cause JDBC connection leaks in other unit tests.
### `CodeCachePoolMXBean` limitation
Currently executing `./mvnw -PnativeTestInShardingSphere -e -T 1C clean verify` will involve warning logs for `com.oracle.svm.core.code.CodeCachePoolMXBean`.
```shell
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
com.oracle.svm.core.code.CodeCachePoolMXBean$CodeAndDataPool.getConstructors()
without it being registered for runtime reflection. Add com.oracle.svm.core.code.CodeCachePoolMXBean$CodeAndDataPool.getConstructors() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getConstructors(DynamicHub.java:1128)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.findConstructors(MBeanIntrospector.java:459)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getClassMBeanInfo(MBeanIntrospector.java:430)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getMBeanInfo(MBeanIntrospector.java:389)
[email protected]/com.sun.jmx.mbeanserver.MBeanSupport.<init>(MBeanSupport.java:137)
[email protected]/com.sun.jmx.mbeanserver.MXBeanSupport.<init>(MXBeanSupport.java:66)
[email protected]/javax.management.StandardMBean.construct(StandardMBean.java:174)
[email protected]/javax.management.StandardMBean.<init>(StandardMBean.java:268)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
com.oracle.svm.core.code.CodeCachePoolMXBean$NativeMetadataPool.getConstructors()
without it being registered for runtime reflection. Add com.oracle.svm.core.code.CodeCachePoolMXBean$NativeMetadataPool.getConstructors() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getConstructors(DynamicHub.java:1128)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.findConstructors(MBeanIntrospector.java:459)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getClassMBeanInfo(MBeanIntrospector.java:430)
[email protected]/com.sun.jmx.mbeanserver.MBeanIntrospector.getMBeanInfo(MBeanIntrospector.java:389)
[email protected]/com.sun.jmx.mbeanserver.MBeanSupport.<init>(MBeanSupport.java:137)
[email protected]/com.sun.jmx.mbeanserver.MXBeanSupport.<init>(MXBeanSupport.java:66)
[email protected]/javax.management.StandardMBean.construct(StandardMBean.java:174)
[email protected]/javax.management.StandardMBean.<init>(StandardMBean.java:268)
```
The relevant warning cannot be avoided on `GraalVM CE For JDK 24.0.2`.
Because the no-argument constructor of `com.oracle.svm.core.code.CodeCachePoolMXBean` is marked as an element that is only visible during Native Image generation and cannot be used at Runtime,
regardless of the actual Platform,
through the Java class `org.graalvm.nativeimage.Platform.HOSTED_ONLY`.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ cd ./shardingsphere/
```shell
git clone [email protected]:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+AddAllCharsets,-H:+IncludeAllLocales,--static-nolibc" clean package
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+UnlockExperimentalVMOptions,-H:+AddAllCharsets,-H:+IncludeAllLocales,--static-nolibc" clean package
```

#### 构建完全静态链接的 GraalVM Native Image
Expand All @@ -298,7 +298,7 @@ cd ./shardingsphere/
```shell
git clone [email protected]:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+AddAllCharsets,-H:+IncludeAllLocales,--static,--libc=musl" clean package
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+UnlockExperimentalVMOptions,-H:+AddAllCharsets,-H:+IncludeAllLocales,--static,--libc=musl" clean package
```

#### 使用 GraalVM Native Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ You can execute the following command to build.
```shell
git clone [email protected]:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+AddAllCharsets,-H:+IncludeAllLocales,--static-nolibc" clean package
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+UnlockExperimentalVMOptions,-H:+AddAllCharsets,-H:+IncludeAllLocales,--static-nolibc" clean package
```

#### Build a fully statically linked GraalVM Native Image
Expand All @@ -302,7 +302,7 @@ You can execute the following command to build.
```shell
git clone [email protected]:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+AddAllCharsets,-H:+IncludeAllLocales,--static,--libc=musl" clean package
./mvnw -am -pl distribution/proxy-native -T1C -DskipTests "-Prelease.native" "-DbuildArgs=-H:+UnlockExperimentalVMOptions,-H:+AddAllCharsets,-H:+IncludeAllLocales,--static,--libc=musl" clean package
```

#### Use GraalVM Native Image
Expand Down
Loading
Loading