-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
feature: support native-image
for seata-client
#5476
feature: support native-image
for seata-client
#5476
Conversation
This reverts commit d21be4c.
…eata/*`, and remove the `aot.factories` of the `SeataServicesRuntimeHints`.
2) Optimize `test.yml` .
# Conflicts: # changes/en-us/develop.md # changes/zh-cn/develop.md # core/src/main/java/io/seata/core/protocol/Version.java # core/src/test/java/io/seata/core/protocol/VersionTest.java
# Conflicts: # .github/workflows/publishes.yml
if (!Map.class.isAssignableFrom(field.getType())) { | ||
field.setAccessible(true); | ||
return field.get(propertyObj); | ||
} | ||
} catch (NoSuchFieldException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
字段未找到时,就用方法获取。
因为在native-image中,有可能未注册fields,但注册了methods,可以通过method获取到配置值。
native-image
for seata-client
@slievrly PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
native-image
for seata-client
native-image
for seata-client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return (Configuration)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Configuration.class} | ||
, (proxy, method, args) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @funky-eyes
- As a solution to No classes have been predefined during the image build to load from bytecodes at runtime raphw/byte-buddy#1588 , can we port the handling of
ConfigurationCache.java
back to the 2.x branch? - Reference https://github.com/apache/incubator-seata/blob/2.x/config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @funky-eyes
- As a solution to No classes have been predefined during the image build to load from bytecodes at runtime raphw/byte-buddy#1588 , can we port the handling of
ConfigurationCache.java
back to the 2.x branch?- Reference https://github.com/apache/incubator-seata/blob/2.x/config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java .
针对configuration cache代理这块可以修改为接口的方式使用jdk代理来解决,但是2.0中重构了事务api相关的模块,针对用户发起事务的实例使用了bytebuddy进行了代理,所以我不知道单纯改动configuration cache这个代理为jdk代理是否能解决该问题。
The configuration cache proxy can be modified to use a JDK proxy to address this issue. However, in 2.0, the transaction API-related modules were refactored, and ByteBuddy was used for proxying instances that initiate user transactions. Therefore, I am unsure whether simply changing the configuration cache proxy to a JDK proxy will resolve the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @funky-eyes
- As a solution to No classes have been predefined during the image build to load from bytecodes at runtime raphw/byte-buddy#1588 , can we port the handling of
ConfigurationCache.java
back to the 2.x branch?- Reference https://github.com/apache/incubator-seata/blob/2.x/config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java .
#6386 configurationcache will remove bytebuddy proxy in this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @funky-eyes
- As a solution to No classes have been predefined during the image build to load from bytecodes at runtime raphw/byte-buddy#1588 , can we port the handling of
ConfigurationCache.java
back to the 2.x branch?- Reference https://github.com/apache/incubator-seata/blob/2.x/config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java .
#6386 configurationcache will remove bytebuddy proxy in this pr
- @funky-eyes Late reply, I have verified that the relevant PR is enough to make the AT mode of Seata Client 2.1.0-SNAPSHOT work under GraalVM Native Image. I opened Provide built-in GraalVM Reachability Metadata on Seata Client 2.1.0+ #6686 to ask for further comments.
Ⅰ. Describe what this PR did
feature: First support
native-image
of theseata-client
.新特性:首次针对
native-image
做兼容性改造。已支持的功能:
暂未支持的功能:
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
mvn clean install -DskipTests
,将 jar包 install 到本地仓库。seata-support-aot
分支:https://github.com/wangliang181230/study-spring-boot/tree/seata-support-aottest-compatibility-springboot3-seata
小目录,不是study-spring-boot
大目录。mvn clean package -Pnative -e -DskipTests
,开始打包native-image
seata-server
mysql
,并创建数据库:seata_study
,再运行以下脚本创建表:startup-exe.bat
文件,启动native-image
。http://localhost:8081/
,测试成功情况;http://localhost:8081/?test=1
,测试 insert 语句完成后,抛异常的情况,观察表undo_log
中会有一条数据,等10秒后回滚后被删除。http://localhost:8081/?test=2
,测试 insert 语句 和tcc.prepare
方法完成后,抛异常的情况,观察表undo_log
中会有一条数据,等10秒后回滚后被删除。同时,控制台会打印类似test tcc: rollback......
字样。startup-exe-by-XA-mode.bat
,重复8、9、10步骤,测试XA
模式。Ⅴ. Special notes for reviews
seata-spring-framework-fake-for-java8
模块,仅为了使aot相关代码在java8可以编译通过。使seata
的jar包可以同时兼容高低版本的java
.