You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "linghengqian (via GitHub)" <gi...@apache.org> on 2026/09/30 09:47:50 UTC

[PR] Tolerate shutdown and configuration-removal races [shardingsphere-elasticjob]

linghengqian opened a new pull request, #2550:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/2550

   For #2549 .
   
   Changes proposed in this pull request:
   - Tolerate shutdown and configuration-removal races. 
     - Fixes the issue that a job execution keeps running after the job is shut down.
     - Fixes the issue that the leader election throws a null pointer exception after the job is shut down.
     - Fixes the issue that a scheduled trigger throws an exception after the job configuration is removed.
     - Fixes the issue that the failover listener throws an exception when the job configuration is removed.
     - Fixes the issue that the sharding listener throws a null pointer exception when the job configuration is removed.
     - Fixes the issue that the static sharding listener throws an exception when the job configuration is removed.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Tolerate shutdown and configuration-removal races [shardingsphere-elasticjob]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on code in PR #2550:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/2550#discussion_r4144312067


##########
examples/elasticjob-example-java/src/main/java/org/apache/shardingsphere/elasticjob/example/JavaMain.java:
##########
@@ -73,9 +83,6 @@ public static void main(final String[] args) throws IOException {
         setUpDataflowJob(regCenter, tracingConfig);
         setUpScriptJob(regCenter, tracingConfig);
         setUpOneOffJob(regCenter, tracingConfig);
-//        setUpOneOffJobWithEmail(regCenter, tracingConfig);
-//        setUpOneOffJobWithDingtalk(regCenter, tracingConfig);
-//        setUpOneOffJobWithWechat(regCenter, tracingConfig);

Review Comment:
   Why to remove the demo code?



##########
kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/LiteJob.java:
##########
@@ -35,11 +36,20 @@ public final class LiteJob implements InterruptableJob {
     
     private volatile Thread currentThread;
     
+    /**
+     * Execute the job.
+     *
+     * <p>
+     * A {@link JobConfigurationException} is swallowed here, because a trigger may still fire after the job
+     * configuration has been removed, and in that case there is nothing left to execute.
+     * </p>
+     */

Review Comment:
   @Override methods do not need javadoc



##########
examples/elasticjob-example-spring/src/main/java/org/apache/shardingsphere/elasticjob/example/SpringMain.java:
##########
@@ -28,8 +36,5 @@ public static void main(final String[] args) {
     // CHECKSTYLE:ON
         EmbedZookeeperServer.start(EMBED_ZOOKEEPER_PORT);
         ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/application-context.xml");
-        // One-off Job
-        //OneOffJobBootstrap oneOffJobBootstrap = context.getBean("oneOffJobBean", OneOffJobBootstrap.class);
-        //oneOffJobBootstrap.execute();

Review Comment:
   Why remove the codes, is it related with the issue?



##########
kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/schedule/JobScheduler.java:
##########
@@ -197,11 +197,18 @@ private void registerStartUpInfo() {
     
     /**
      * Shutdown job.
+     *
+     * <p>
+     * The schedule controller is stopped before the registry center is torn down, so that no job execution outlives
+     * it and keeps reading a configuration which has already been removed. {@code waitForJobsToComplete} must stay
+     * {@code false}: Quartz only calls {@code interruptJob()} in that case, whereas waiting for the execution to
+     * finish on its own can block forever because this method still holds the {@link JobScheduleController} monitor.
+     * </p>

Review Comment:
   Any reason to modify javadoc?



##########
kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/sharding/ShardingListenerManager.java:
##########
@@ -90,8 +104,23 @@ public void onChange(final DataChangedEvent event) {
             }
         }
         
+        /**
+         * Judge whether the job uses static sharding.
+         *
+         * <p>
+         * A removed job configuration yields {@code false} instead of propagating the exception, because a
+         * configuration change event may still be delivered after the job is shut down and there is nothing left to
+         * reshard then.
+         * </p>
+         *
+         * @return whether the job uses static sharding
+         */

Review Comment:
   Please remove javadoc for private methods



##########
registry-center/provider/etcd/src/main/java/org/apache/shardingsphere/elasticjob/reg/etcd/EtcdRegistryCenter.java:
##########
@@ -335,6 +335,13 @@ public Object getRawClient() {
         return client;
     }
     
+    /**
+     * Execute the callback while the given key is leader.
+     *
+     * <p>
+     * A failed lease revocation is ignored, because the lease will expire automatically or be revoked on close.
+     * </p>
+     */

Review Comment:
   Please remove javadoc for overrided methods



##########
RELEASE-NOTES.md:
##########
@@ -12,6 +12,12 @@
 
 1. Kernel: Fixes the issue that the distributed once listener loops forever when the registration is not confirmed by the registry center - [#2543](https://github.com/apache/shardingsphere-elasticjob/issues/2543)
 1. Kernel: Fixes the issue that the trigger flag is removed before the job is triggered - [#2543](https://github.com/apache/shardingsphere-elasticjob/issues/2543)
+1. Kernel: Fixes the issue that a job execution keeps running after the job is shut down - [#2550](https://github.com/apache/shardingsphere-elasticjob/pull/2550)
+1. Kernel: Fixes the issue that the leader election throws a null pointer exception after the job is shut down - [#2550](https://github.com/apache/shardingsphere-elasticjob/pull/2550)
+1. Kernel: Fixes the issue that a scheduled trigger throws an exception after the job configuration is removed - [#2550](https://github.com/apache/shardingsphere-elasticjob/pull/2550)
+1. Kernel: Fixes the issue that the failover listener throws an exception when the job configuration is removed - [#2550](https://github.com/apache/shardingsphere-elasticjob/pull/2550)
+1. Kernel: Fixes the issue that the sharding listener throws a null pointer exception when the job configuration is removed - [#2550](https://github.com/apache/shardingsphere-elasticjob/pull/2550)
+1. Kernel: Fixes the issue that the static sharding listener throws an exception when the job configuration is removed - [#2550](https://github.com/apache/shardingsphere-elasticjob/pull/2550)

Review Comment:
   Could you summarize the release notes?



##########
restful/src/test/java/org/apache/shardingsphere/elasticjob/restful/pipeline/NettyRestfulServiceTest.java:
##########
@@ -90,24 +90,36 @@ void assertRequestWithParameters() throws UnsupportedEncodingException {
         }, TESTCASE_TIMEOUT);
     }
     
+    /**
+     * Assert custom exception handler.
+     *
+     * <p>
+     * The exception is handled by the custom exception handler and returns HTTP status 403.
+     * </p>
+     */

Review Comment:
   Please remove javadoc for test cases



##########
kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManager.java:
##########
@@ -80,8 +81,22 @@ public void start() {
         addDataListener(new LegacyCrashedRunningItemListener());
     }
     
+    /**
+     * Judge whether failover is enabled.
+     *
+     * <p>
+     * A removed job configuration yields {@code false} instead of propagating the exception, because a configuration
+     * change event may still be delivered after the job is shut down and there is nothing left to fail over then.
+     * </p>
+     *
+     * @return whether failover is enabled
+     */

Review Comment:
   Private methods do not need javadocs



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fixes the issues that a job keeps running or throws an exception after it is shut down or its configuration is removed [shardingsphere-elasticjob]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu merged PR #2550:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/2550


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org