Split out the unrelated changes bundled in PR #2548
Feature Request
For English only, other languages will not accept.
Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot make decision by current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Is your feature request related to a problem?
Describe the feature you would like.
#2548 is titled Spring Boot Starter and Spring Namespace support etcd, Nacos and in-memory registry centers, but it also carries a number of changes that are not about Spring at all: five kernel files fixing job shutdown and configuration-removal races, two registry-center files handling a closed ZooKeeper client, the whole reachability-metadata generation pipeline, a CI action bump, and some documentation fixes. It is the same situation that #2540 ended up in, which was split in #2543, and this issue tracks the equivalent split for #2548. The items below are intended to land as separate PRs.
The kernel and registry-center items all trace back to one class of problem. The build and GraalVM CI jobs run with -T1C, so several test JVMs execute concurrently and each embeds its own ZooKeeper, Nacos or etcd server; under CPU contention the registry client sessions churn and in-flight reads race the client shutdown, surfacing as IllegalStateException: Client is not started or has been closed, CuratorClosedException: Expected state [STARTED] was [STOPPED], and JobConfigurationException: JobConfiguration was not found. A second, independent source is the shutdown path itself: both ElasticJob.shutdown() and JobConfigurationAPI.removeJobConfiguration() stop a job while Quartz workers and registry watch listeners are still live, so those workers keep failing against a configuration that is already gone. The ERROR count in a metadata-generation build has been 12, 2, 4, 4, 0, 0, 2 and 0 across consecutive runs of identical code, so the noise is timing-dependent rather than deterministic; every distinct surfacing point has been identified and is covered below, though individual runs may print nothing either way.
The build and metadata items are about the -PgenerateMetadata pipeline rather than any product behaviour, and they exist because of two limitations in the native-maven-plugin. metadata-copy cannot be used to merge the agent output, because with metadataCopy.merge=false it only feeds target/native/agent-output/test into native-image-configure while the tracing agent writes its reports under agent-output/test/session-{pid}-{datetime}/partial-config-with-origins.json, so without a merge the goal copies a two-byte {}. merge-agent-files cannot be a CLI goal either, since its context parameter is required=true with no default and is not editable, and only the plugin's NativeExtension injects context into executions; it therefore has to be a bound execution. Separately, metadata-copy has a silent-exit path when the agent configuration is absent or the agent is neither enabled in configuration nor through the agent system property, which is what makes it possible to scope the agent to a single module.
- Kernel: tolerate shutdown and configuration-removal races —
JobScheduler,LiteJob,LeaderService,FailoverListenerManager,ShardingListenerManager. MovejobScheduleController.shutdown()ahead of the registry teardown so that no execution outlives the registry center. KeepwaitForJobsToCompleteset tofalse: Quartz only callsinterruptJob()in that case, andtrueblocks indefinitely whileJobScheduleControllerstill holds its monitor, which hangsScheduleJobBootstrapTestoutright. SwallowJobConfigurationExceptioninLiteJob.execute()so that a trigger firing after removal does not reach Quartz'sJobRunShell. Make the leader-election callback null-safe ongetJobInstance(). Tolerate a removed configuration inFailoverListenerManager.isFailoverEnabled()andShardingListenerManager.isStaticSharding(). Treat a deleted configuration node as an empty value inShardingTotalCountChangedJobListener, because etcd delivers the removed node's value andYamlEngine.unmarshal()returns null for it. - Registry center: closed-client reads and nested interrupts —
ZookeeperRegistryCenter,RegExceptionHandler. TheisClientClosed()guard at the top ofgetDirectly(),getChildrenKeys()andisExisted()is defeated by a TOCTOU window: the Curator client can be closed between the check and the call, in which caseRegExceptionHandler.handleException()throws and the fallbackreturnbecomes dead code, so the state needs to be re-checked after the call. Treat anInterruptedExceptionnested in a wrapper as an interruption, by restoring the interrupt flag instead of wrapping it inRegException, since a job aborted by a shutdown interrupt currently propagates out ofLiteJob.execute()into Quartz and is logged as an unhandled exception. - Build: rewire the reachability-metadata generation pipeline — root
pom.xml,test/native/pom.xml,test/native/native-image-filter/extra-filter.json. Bindmerge-agent-filesas an execution at thetestphase and drop thebuild-nativeandtest-nativeexecutions. Replace the hardcoded<agent><enabled>with anative.agent.enabledproperty that defaults tofalseand is flipped totrueonly by the profile, so the 37 non-native modules in the reactor stop printingCannot find source directorywhen the CLImetadata-copygoal is run across all 38. Add the fourexcludeClassesfilters. - Regenerate the GraalVM reachability metadata —
reachability-metadata/.../generated-reachability-metadata/reachability-metadata.json, +230 / −128 lines. It is a byproduct of the pipeline change above and its output is non-deterministic, so it should land together with that item. It also still lacks the four shaded Nacos gRPC SPI entriescom.alibaba.nacos.shaded.io.grpc.LoadBalancerProvider,ManagedChannelProvider,NameResolverProviderandServerProvider, becauseextra-filter.jsonexcludescom.**; a conditional-mode agent cannot record accesses made by filtered classes, so those four would need an unconditional, resources-onlyreachability-metadata.jsonunderMETA-INF/native-image/com.alibaba.nacos/nacos-client/3.2.4/. That is a separate item in its own right if native Nacos is wanted. - CI: bump
graalvm/setup-graalvmfrom v1.5.6 to v1.6.6 —.github/workflows/graalvm.yml, one line. While that file is being touched it is worth revisiting thepathsfilter, which only coversgraalvm.yml,reachability-metadata/src/**,test/native/native-image-filter/**andtest/native/src/**, and therefore does not trigger onkernel/**,registry-center/**,spring/**orpom.xml, and thegithub.repository == 'apache/shardingsphere-elasticjob'gate, which silently disables the job on forks. - Docs: correctness fixes outside the Spring pages —
docs/content/user-manual/configuration/graalvm-native-image.{en,cn}.md,java-api.{en,cn}.md,registry-center/_index.{en,cn}.md,registry-center/etcd.{en,cn}.md,registry-center/zookeeper.{en,cn}.md. The GraalVM page fixes the repository name in the clone commands, corrects the module name in the classpath instruction, and notes that the trailingnative:metadata-copygoal is optional.java-apistill says the registry center "currently only supportsZooKeeper" and is missing anensembleTrackertable row. Theregistry-centerindex pages shed most of their content as it moved into the new per-center pages. - Tests: native image coverage for the memory and Nacos registry centers —
test/native/.../memory/MemoryJavaTest,MemoryOperationJavaTest,.../staticd/SpringBootMemoryRegistryCenterTestand.../nacos/NacosJavaTest. These assert native-image compatibility of the new registry centers, which is a different concern from the Spring Boot Starter and Spring Namespace wiring, so they could move over to the native-image work. If maintainers consider native coverage part of this feature, this item can stay in#2548. - Tests: drop the obsolete
JavaTestTODO and widen the sharding readiness wait —test/native/.../operation/JavaTest.java. The TODO documenting thatremoveJobConfiguration()always makes a listener throw is obsolete once the kernel and registry-center items land. Separately, theAwaitility.untilpredicate only waited for the sharding count to reach three, but a returnedShardingInfocan still have a nullserverIp, so the wait now also requires every entry to be populated and reuses the fetched collection instead of callinggetShardingInfo()a second time.
Each of the kernel and registry-center items is a user-visible behaviour change and already has a RELEASE-NOTES.md entry under the 3.0.6-SNAPSHOT Bug Fixes section, so those entries should move with their code. The items have been verified together on this branch: ./mvnw -PgenerateMetadata -e -T1C clean test native:metadata-copy finishes with BUILD SUCCESS and no ERROR lines, the full unit test suite passes with 845 tests and no failures, and checkstyle reports no violations. One caveat worth knowing when reviewing the kernel items: the generateMetadata profile restricts the surefire includes to org.apache.shardingsphere.elasticjob.test.natived.**, so that command only runs the 41 native image integration tests and no unit tests at all. A full unit test run needs to be executed separately for any kernel change.
Source: apache/shardingsphere-elasticjob