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

Enable Safe Composition of Metadata for ShardingSphere Proxy Native #33179

Merged
merged 1 commit into from
Oct 11, 2024
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
1. DistSQL: Support connecting to Postgres via DistSQL in Proxy Native - [#33124](https://github.com/apache/shardingsphere/pull/33124)
1. DistSQL: Check duplicate actual data nodes when creating or altering sharding table rule - [#33138](https://github.com/apache/shardingsphere/pull/33138)
1. DistSQL: Check user privilege when registering or altering storage unit - [#32172](https://github.com/apache/shardingsphere/pull/32172)
1. Infra: Enable Safe Composition of Metadata for ShardingSphere Proxy Native - [#33179](https://github.com/apache/shardingsphere/pull/33179)

### Bug Fix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ Caused by: java.io.UnsupportedEncodingException: Codepage Cp1252 is not supporte
```json
[
{
"condition":{"typeReachable":"com.mysql.cj.jdbc.MysqlXADataSource"},
"name":"com.mysql.cj.jdbc.MysqlXADataSource",
"allDeclaredConstructors": true
"condition":{"typeReachable":"com.mysql.cj.jdbc.MysqlXADataSource"},
"name":"com.mysql.cj.jdbc.MysqlXADataSource",
"allPublicMethods": true,
"methods": [{"name":"<init>","parameterTypes":[] }]
}
]
```
Expand Down Expand Up @@ -484,7 +485,7 @@ sudo apt-get install build-essential zlib1g-dev -y

git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -PnativeTestInShardingSphere -e clean test
./mvnw -PnativeTestInShardingSphere -e -T 1C clean test
```

当贡献者发现缺少与 ShardingSphere 无关的第三方库的 GraalVM Reachability Metadata 时,应当在
Expand Down Expand Up @@ -513,10 +514,26 @@ Reachability Metadata 位于 `shardingsphere-infra-reachability-metadata` 子模
```bash
git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -PgenerateMetadata -DskipNativeTests -e clean test native:metadata-copy
./mvnw -PgenerateMetadata -DskipNativeTests -e -T 1C clean test native:metadata-copy
```

在使用 GraalVM Native Build Tools 的 Maven Plugin 时,
贡献者应避免使用 Maven 的并行构建功能。
GraalVM Native Build Tools 的 Maven Plugin并不是线程安全的,
它与 https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3 不兼容。
受 https://github.com/apache/shardingsphere/issues/33206 影响,
贡献者执行 `./mvnw -PgenerateMetadata -DskipNativeTests -T 1C -e clean test native:metadata-copy` 后,
`infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json` 会生成不必要的包含绝对路径的 JSON 条目,
类似如下,

```json
{
"resources":{
"includes":[{
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader"},
"pattern":"\\QcustomPath/shardingsphere/test/native/src/test/resources/test-native/yaml/proxy/databases/postgresql//global.yaml\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader"},
"pattern":"\\QcustomPath/shardingsphere/test/native/src/test/resources/test-native/yaml/proxy/databases/postgresql/\\E"
}]},
"bundles":[]
}
```

贡献者应始终手动删除这些包含绝对路径的 JSON 条目,并等待 https://github.com/oracle/graal/issues/8417 被解决。
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ to define the constructor of `com.mysql.cj.jdbc.MysqlXADataSource` inside the Gr
```json
[
{
"condition":{"typeReachable":"com.mysql.cj.jdbc.MysqlXADataSource"},
"name":"com.mysql.cj.jdbc.MysqlXADataSource",
"allDeclaredConstructors": true
"condition":{"typeReachable":"com.mysql.cj.jdbc.MysqlXADataSource"},
"name":"com.mysql.cj.jdbc.MysqlXADataSource",
"allPublicMethods": true,
"methods": [{"name":"<init>","parameterTypes":[] }]
}
]
```
Expand Down Expand Up @@ -502,7 +503,7 @@ sudo apt-get install build-essential zlib1g-dev -y

git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -PnativeTestInShardingSphere -e clean test
./mvnw -PnativeTestInShardingSphere -e -T 1C clean test
```

When contributors discover that GraalVM Reachability Metadata is missing for a third-party library not related to ShardingSphere,
Expand Down Expand Up @@ -532,8 +533,26 @@ contributors should place it on the classpath of the `shardingsphere-test-native
```bash
git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -PgenerateMetadata -DskipNativeTests -e clean test native:metadata-copy
./mvnw -PgenerateMetadata -DskipNativeTests -e -T 1C clean test native:metadata-copy
```

Contributors should avoid using Maven's parallel builds feature when using the Maven Plugin for GraalVM Native Build Tools.
The Maven Plugin for GraalVM Native Build Tools is not thread-safe and is incompatible with https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3 .
Affected by https://github.com/apache/shardingsphere/issues/33206 ,
After the contributor executes `./mvnw -PgenerateMetadata -DskipNativeTests -T 1C -e clean test native:metadata-copy`,
`infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json` will generate unnecessary JSON entries containing absolute paths,
similar to the following.

```json
{
"resources":{
"includes":[{
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader"},
"pattern":"\\QcustomPath/shardingsphere/test/native/src/test/resources/test-native/yaml/proxy/databases/postgresql//global.yaml\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader"},
"pattern":"\\QcustomPath/shardingsphere/test/native/src/test/resources/test-native/yaml/proxy/databases/postgresql/\\E"
}]},
"bundles":[]
}
```

Contributors should always manually remove these JSON entries containing absolute paths and wait for https://github.com/oracle/graal/issues/8417 to be resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"name":"ch.qos.logback.core.OutputStreamAppender",
"methods":[{"name":"setEncoder","parameterTypes":["ch.qos.logback.core.encoder.Encoder"] }]
},
{
"condition":{"typeReachable":"ch.qos.logback.core.joran.action.NestedComplexPropertyIA"},
"name":"ch.qos.logback.core.encoder.Encoder",
"methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"ch.qos.logback.core.joran.util.PropertySetter"},
"name":"ch.qos.logback.core.encoder.LayoutWrappingEncoder",
Expand All @@ -64,6 +69,11 @@
"name":"ch.qos.logback.core.pattern.PatternLayoutEncoderBase",
"methods":[{"name":"setPattern","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"ch.qos.logback.core.joran.action.NestedComplexPropertyIA"},
"name":"ch.qos.logback.core.spi.ContextAware",
"methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"ch.qos.logback.core.joran.action.StatusListenerAction"},
"name":"ch.qos.logback.core.status.NopStatusListener",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"condition":{"typeReachable":"com.alibaba.druid.mock.MockDriver"},
"name":"com.alibaba.druid.mock.MockDriver",
"queryAllPublicConstructors":true
},
{
"condition":{"typeReachable":"com.alibaba.druid.mock.MockDriver"},
"name":"com.alibaba.druid.mock.MockDriverMBean",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"com.alibaba.druid.proxy.DruidDriver"},
"name":"com.alibaba.druid.proxy.DruidDriver",
"queryAllPublicConstructors":true
},
{
"condition":{"typeReachable":"com.alibaba.druid.proxy.DruidDriver"},
"name":"com.alibaba.druid.proxy.DruidDriverMBean",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.LogFactory"},
"name":"com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.Resources"},
"name":"com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl"
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.LogFactory"},
"name":"com.alibaba.druid.support.logging.Jdk14LoggingImpl",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.Resources"},
"name":"com.alibaba.druid.support.logging.Jdk14LoggingImpl"
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.LogFactory"},
"name":"com.alibaba.druid.support.logging.NoLoggingImpl",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.LogFactory"},
"name":"com.alibaba.druid.support.logging.SLF4JImpl",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"com.alibaba.druid.support.logging.Resources"},
"name":"com.alibaba.druid.support.logging.SLF4JImpl"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"resources":{
"includes":[{
"condition":{"typeReachable":"com.alibaba.druid.util.JdbcUtils"},
"pattern":"\\QMETA-INF/druid-driver.properties\\E"
}]},
"bundles":[]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"condition":{"typeReachable":"com.atomikos.logging.LoggerFactory"},
"name":"com.atomikos.logging.Slf4JLoggerFactoryDelegate",
"methods":[{"name":"<init>","parameterTypes":[] }]
}
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"resources":{
"includes":[{
"condition":{"typeReachable":"com.clickhouse.logging.LoggerFactory"},
"pattern":"\\QMETA-INF/services/com.clickhouse.logging.LoggerFactory\\E"
}]},
"bundles":[]
}

This file was deleted.

Loading