You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "tiagodolphine (via GitHub)" <gi...@apache.org> on 2023/09/28 16:20:13 UTC

[GitHub] [incubator-kie-kogito-apps] tiagodolphine opened a new pull request, #1888: [KOGITO-9842] The initial load job task from DB is not executed Job Service

tiagodolphine opened a new pull request, #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888

   Many thanks for submitting your Pull Request :heart:! 
   
   Please make sure that your PR meets the following requirements:
   
   - [ ] You have read the [contributors guide](https://github.com/apache/incubator-kie-kogito-runtimes#contributing-to-kogito)
   - [ ] Pull Request title is properly formatted: `KOGITO-XYZ Subject`
   - [ ] Pull Request title contains the target branch if not targeting main: `[0.9.x] KOGITO-XYZ Subject`
   - [ ] Pull Request contains link to the JIRA issue
   - [ ] Pull Request contains link to any dependent or related Pull Request
   - [ ] Pull Request contains description of the issue
   - [ ] Pull Request does not include fixes for issues other than the main ticket
   
   <details>
   <summary>
   How to replicate CI configuration locally?
   </summary>
   
   Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use [build-chain tool](https://github.com/kiegroup/github-action-build-chain) to handle cross repository builds and be sure that we always use latest version of the code for each repository.
    
   [build-chain tool](https://github.com/kiegroup/github-action-build-chain) is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See [local execution](https://github.com/kiegroup/github-action-build-chain#local-execution) details to get more information about it.
   </details>
   
   <details>
   <summary>
   How to retest this PR or trigger a specific build:
   </summary>
   
   - for <b>pull request checks</b>  
     Please add comment: <b>Jenkins retest this</b>
   
   - for a <b>specific pull request check</b>  
     Please add comment: <b>Jenkins (re)run [kogito-apps|kogito-examples] tests</b>
   
   - for <b>quarkus branch checks</b>  
     Run checks against Quarkus current used branch  
     Please add comment: <b>Jenkins run quarkus-branch</b>
   
   - for a <b>quarkus branch specific check</b>  
     Run checks against Quarkus current used branch  
     Please add comment: <b>Jenkins (re)run [kogito-apps|kogito-examples] quarkus-branch</b>
   
   - for <b>quarkus main checks</b>  
     Run checks against Quarkus main branch  
     Please add comment: <b>Jenkins run quarkus-main</b>
   
   - for a <b>specific quarkus main check</b>  
     Run checks against Quarkus main branch  
     Please add comment: <b>Jenkins (re)run [kogito-apps|kogito-examples] quarkus-main</b>
   
   - for <b>quarkus lts checks</b>  
     Run checks against Quarkus lts branch  
     Please add comment: <b>Jenkins run quarkus-lts</b>
   
   - for a <b>specific quarkus lts check</b>  
     Run checks against Quarkus lts branch  
     Please add comment: <b>Jenkins (re)run [kogito-apps|kogito-examples] quarkus-lts</b>
    
   - for <b>native checks</b>  
     Run native checks  
     Please add comment: <b>Jenkins run native</b>
   
   - for a <b>specific native check</b>  
     Run native checks 
     Please add comment: <b>Jenkins (re)run [kogito-apps|kogito-examples] native</b>
   
   - for <b>native lts checks</b>  
     Run native checks against quarkus lts branch
     Please add comment: <b>Jenkins run native-lts</b>
   
   - for a <b>specific native lts check</b>  
     Run native checks against quarkus lts branch
     Please add comment: <b>Jenkins (re)run [kogito-apps|kogito-examples] native-lts</b>
    
   </details>
   
   <details>
   <summary>
   How to backport a pull request to a different branch?
   </summary>
   
   In order to automatically create a **backporting pull request** please add one or more labels having the following format `backport-<branch-name>`, where `<branch-name>` is the name of the branch where the pull request must be backported to (e.g., `backport-7.67.x` to backport the original PR to the `7.67.x` branch).
   
   > **NOTE**: **backporting** is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another.
   
   Once the original pull request is successfully merged, the automated action will create one backporting pull request per each label (with the previous format) that has been added.
   
   If something goes wrong, the author will be notified and at this point a manual backporting is needed.
   
   > **NOTE**: this automated backporting is triggered whenever a pull request on `main` branch is labeled or closed, but both conditions must be satisfied to get the new PR created.
   </details>
   
   <details>
   <summary>
   Quarkus-3 PR check is failing ... what to do ?
   </summary>
   The Quarkus 3 check is applying patches from the `.ci/environments/quarkus-3/patches`.
   
   The first patch, called `0001_before_sh.patch`, is generated from Openrewrite `.ci/environments/quarkus-3/quarkus3.yml` recipe. The patch is created to speed up the check. But it may be that some changes in the PR broke this patch.  
   No panic, there is an easy way to regenerate it. You just need to comment on the PR:
   ```
   jenkins rewrite quarkus-3
   ```
   and it should, after some minutes (~20/30min) apply a commit on the PR with the patch regenerated.
   
   Other patches were generated manually. If any of it fails, you will need to manually update it... and push your changes.
   </details>


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "kie-ci3 (via GitHub)" <gi...@apache.org>.
kie-ci3 commented on PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#issuecomment-1785912703

   
   **PR job** `#8` was: **UNSTABLE**
   Possible explanation: This should be test failures
   
   
   <details>
   <summary><b>Reproducer</b></summary>
   
   
   
   build-chain build full_downstream  -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-apps -u https://github.com/apache/incubator-kie-kogito-apps/pull/1888 --skipParallelCheckout
   
   NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution
   
   </details>
   
   
   Please look here: https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/8/display/redirect
   
   **Test results:**
   - PASSED: 2818
   - FAILED: 1
   
   Those are the test failures: 
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/8/testReport/org.kie.kogito.persistence.oracle/OracleStorageServiceIT/testQuery_Equal/">org.kie.kogito.persistence.oracle.OracleStorageServiceIT.testQuery_Equal</a></summary>
   Error invoking subclass method
   </details>
   


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


[GitHub] [incubator-kie-kogito-apps] wmedvede commented on a diff in pull request #1888: [KOGITO-9842] The initial load job task from DB is not executed Job Service

Posted by "wmedvede (via GitHub)" <gi...@apache.org>.
wmedvede commented on code in PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#discussion_r1341445092


##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -73,26 +74,49 @@ public class JobSchedulerManager {
 
     @Inject
     Vertx vertx;
-    private AtomicBoolean enabled = new AtomicBoolean(false);
+    final AtomicBoolean enabled = new AtomicBoolean(false);
+
+    final AtomicLong periodicTimerIdForLoadJobs = new AtomicLong(-1l);
 
     void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupEvent startupEvent) {
-        if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
-            LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
-                    "setting value {} for both",
-                    loadJobIntervalInMinutes,
-                    schedulerChunkInMinutes,
-                    schedulerChunkInMinutes);
-            loadJobIntervalInMinutes = schedulerChunkInMinutes;
+        if (enabled.get()) {

Review Comment:
   if the enabled value can be changed only by the MessagingChangeEvent arrival, and we are already starting the load at this point when needed, I believe we don't need this method any more.



-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


[GitHub] [incubator-kie-kogito-apps] wmedvede commented on a diff in pull request #1888: [KOGITO-9842] The initial load job task from DB is not executed Job Service

Posted by "wmedvede (via GitHub)" <gi...@apache.org>.
wmedvede commented on code in PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#discussion_r1341027956


##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -93,6 +93,8 @@ void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupE
 
     protected void onMessagingStatusChange(@Observes MessagingChangeEvent event) {
         this.enabled.set(event.isEnabled());
+        //run load jobs once the instance become a leader to avoid waiting for the next periodic run
+        vertx.runOnContext(this::loadJobDetails);

Review Comment:
   I believe that by doing this, we might fall in the situation that two loadJobDetails can be executing at the same time, not good.
   
   This is the scenario:
   1) loadJobDetails_programmed is about to start, let's say in 5 ms
   2) The events arrive and loadJobDetails_2 is launched
   3) loadJDetals_programmed starts
   4) loadJobDetils_programmed and loadJobDetails_2 executes at the same time.
   
   To do this "forced" start with the event we might probably need a synchronized queue to store the loadJobDetails work, or some other mechanism.
   
   



-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#issuecomment-1790274405

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_incubator-kie-kogito-apps&pullRequest=1888)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-kie-kogito-apps&pullRequest=1888&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_incubator-kie-kogito-apps&pullRequest=1888) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_incubator-kie-kogito-apps&pullRequest=1888&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


[GitHub] [incubator-kie-kogito-apps] tiagodolphine commented on a diff in pull request #1888: [KOGITO-9842] The initial load job task from DB is not executed Job Service

Posted by "tiagodolphine (via GitHub)" <gi...@apache.org>.
tiagodolphine commented on code in PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#discussion_r1341310736


##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -93,6 +93,8 @@ void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupE
 
     protected void onMessagingStatusChange(@Observes MessagingChangeEvent event) {
         this.enabled.set(event.isEnabled());
+        //run load jobs once the instance become a leader to avoid waiting for the next periodic run
+        vertx.runOnContext(this::loadJobDetails);

Review Comment:
   @wmedvede I updated the PR



-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


[GitHub] [incubator-kie-kogito-apps] wmedvede commented on a diff in pull request #1888: [KOGITO-9842] The initial load job task from DB is not executed Job Service

Posted by "wmedvede (via GitHub)" <gi...@apache.org>.
wmedvede commented on code in PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#discussion_r1341445092


##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -73,26 +74,49 @@ public class JobSchedulerManager {
 
     @Inject
     Vertx vertx;
-    private AtomicBoolean enabled = new AtomicBoolean(false);
+    final AtomicBoolean enabled = new AtomicBoolean(false);
+
+    final AtomicLong periodicTimerIdForLoadJobs = new AtomicLong(-1l);
 
     void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupEvent startupEvent) {
-        if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
-            LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
-                    "setting value {} for both",
-                    loadJobIntervalInMinutes,
-                    schedulerChunkInMinutes,
-                    schedulerChunkInMinutes);
-            loadJobIntervalInMinutes = schedulerChunkInMinutes;
+        if (enabled.get()) {

Review Comment:
   if the enabled value an be changed only by the MessagingChangeEvent arrival, and we are already starting the load at this point when needed, I believe we don't need this method any more.



##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -73,26 +74,49 @@ public class JobSchedulerManager {
 
     @Inject
     Vertx vertx;
-    private AtomicBoolean enabled = new AtomicBoolean(false);
+    final AtomicBoolean enabled = new AtomicBoolean(false);
+
+    final AtomicLong periodicTimerIdForLoadJobs = new AtomicLong(-1l);
 
     void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupEvent startupEvent) {
-        if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
-            LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
-                    "setting value {} for both",
-                    loadJobIntervalInMinutes,
-                    schedulerChunkInMinutes,
-                    schedulerChunkInMinutes);
-            loadJobIntervalInMinutes = schedulerChunkInMinutes;
+        if (enabled.get()) {
+            startJobsLoadingFromRepositoryTask();
         }
+    }
 
-        //first execution
-        vertx.runOnContext(this::loadJobDetails);
-        //periodic execution
-        vertx.setPeriodic(TimeUnit.MINUTES.toMillis(loadJobIntervalInMinutes), id -> loadJobDetails());
+    private void startJobsLoadingFromRepositoryTask() {
+        //guarantee it starts the task just in case it is not already active
+        if (periodicTimerIdForLoadJobs.get() < 0) {
+            if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
+                LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
+                        "setting value {} for both",
+                        loadJobIntervalInMinutes,
+                        schedulerChunkInMinutes,
+                        schedulerChunkInMinutes);
+                loadJobIntervalInMinutes = schedulerChunkInMinutes;
+            }
+            //first execution
+            vertx.runOnContext(this::loadJobDetails);
+            //next executions to run periodically
+            periodicTimerIdForLoadJobs.set(vertx.setPeriodic(TimeUnit.MINUTES.toMillis(loadJobIntervalInMinutes), id -> loadJobDetails()));
+        }
     }
 
-    protected void onMessagingStatusChange(@Observes MessagingChangeEvent event) {
-        this.enabled.set(event.isEnabled());
+    private void cancelJobsLoadingFromRepositoryTask() {
+        if (periodicTimerIdForLoadJobs.get() > 0) {
+            vertx.cancelTimer(periodicTimerIdForLoadJobs.get());
+            //negative id indicates this is not active anymore
+            periodicTimerIdForLoadJobs.set(-1);
+        }
+    }
+
+    protected synchronized void onMessagingStatusChange(@Observes MessagingChangeEvent event) {

Review Comment:
   maybe here we can do this:
   
           if (enabled.get() && !wasEnabled) {
               // good, avoid starting twice if we receive two consecutive enabled = true
               startJobsLoadingFromRepositoryTask();
           } else if (!enabled.get()) {
              // but only cancel if we receive enabled = false, otherwise with two consecutive enable we are also cancelling.
               cancelJobsLoadingFromRepositoryTask();
           }
   
   



-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


[GitHub] [incubator-kie-kogito-apps] tiagodolphine commented on a diff in pull request #1888: [KOGITO-9842] The initial load job task from DB is not executed Job Service

Posted by "tiagodolphine (via GitHub)" <gi...@apache.org>.
tiagodolphine commented on code in PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#discussion_r1341284130


##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -93,6 +93,8 @@ void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupE
 
     protected void onMessagingStatusChange(@Observes MessagingChangeEvent event) {
         this.enabled.set(event.isEnabled());
+        //run load jobs once the instance become a leader to avoid waiting for the next periodic run
+        vertx.runOnContext(this::loadJobDetails);

Review Comment:
   There should be no issue running more than once loadJobDetails, there is a check in the method to avoid scheduling the same job multiple times with a ConcurrentMap. Still, I agree with your point, and this can be improved, let me think a bit and send an update to the PR to improve this process. Thanks for bringing up this point!
   
   https://github.com/apache/incubator-kie-kogito-apps/blob/a9f5d1cb4bb0759ef63facd2b81c8c79da373a18/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java#L105C1-L106C1
   
   https://github.com/apache/incubator-kie-kogito-apps/blob/a9f5d1cb4bb0759ef63facd2b81c8c79da373a18/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/BaseTimerJobScheduler.java#L89C1-L90C1



-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "tiagodolphine (via GitHub)" <gi...@apache.org>.
tiagodolphine merged PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "kie-ci3 (via GitHub)" <gi...@apache.org>.
kie-ci3 commented on PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#issuecomment-1753914495

   
   **PR job** `#1` was: **UNSTABLE**
   Possible explanation: This should be test failures
   
   
   <details>
   <summary><b>Reproducer</b></summary>
   
   
   
   build-chain build full_downstream  -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-apps -u https://github.com/apache/incubator-kie-kogito-apps/pull/1888 --skipParallelCheckout
   
   NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution
   
   </details>
   
   
   Please look here: https://ci-builds.apache.org/job/KIE/job/test/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/display/redirect
   
   **Test results:**
   - PASSED: 2775
   - FAILED: 3
   
   Those are the test failures: 
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/test/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.messaging/InfinispanMessagingApiTest/cancelJob/">org.kie.kogito.jobs.service.messaging.InfinispanMessagingApiTest.cancelJob</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/test/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.repository.infinispan/InfinispanJobRepositoryTest/testFindAll/">org.kie.kogito.jobs.service.repository.infinispan.InfinispanJobRepositoryTest.testFindAll</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/test/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.resource/KeycloakInfinispanJobServiceTest/___/">org.kie.kogito.jobs.service.resource.KeycloakInfinispanJobServiceTest.(?)</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "kie-ci3 (via GitHub)" <gi...@apache.org>.
kie-ci3 commented on PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#issuecomment-1754841796

   
   **PR job** `#5` was: **UNSTABLE**
   Possible explanation: This should be test failures
   
   
   <details>
   <summary><b>Reproducer</b></summary>
   
   
   
   build-chain build full_downstream  -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-apps -u https://github.com/apache/incubator-kie-kogito-apps/pull/1888 --skipParallelCheckout
   
   NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution
   
   </details>
   
   
   Please look here: https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/5/display/redirect
   
   **Test results:**
   - PASSED: 2762
   - FAILED: 4
   
   Those are the test failures: 
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/5/testReport/org.kie.kogito.it.jobs/CallbackStateTimeoutsIT/PR_check___Build_projects___callbackStateTimeoutsExceeded/">PR check / Build projects / org.kie.kogito.it.jobs.CallbackStateTimeoutsIT.callbackStateTimeoutsExceeded</a></summary>
   java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/5/testReport/org.kie.kogito.jobs.service.messaging/InfinispanMessagingApiTest/cancelJob/">org.kie.kogito.jobs.service.messaging.InfinispanMessagingApiTest.cancelJob</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/5/testReport/org.kie.kogito.jobs.service.repository.infinispan/InfinispanJobRepositoryTest/testFindAll/">org.kie.kogito.jobs.service.repository.infinispan.InfinispanJobRepositoryTest.testFindAll</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/5/testReport/org.kie.kogito.jobs.service.resource/KeycloakInfinispanJobServiceTest/___/">org.kie.kogito.jobs.service.resource.KeycloakInfinispanJobServiceTest.(?)</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "wmedvede (via GitHub)" <gi...@apache.org>.
wmedvede commented on PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#issuecomment-1794410799

   @ricardozanini looks like we have greens here! I think we should merge


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "tiagodolphine (via GitHub)" <gi...@apache.org>.
tiagodolphine commented on code in PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#discussion_r1344194907


##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -73,26 +74,49 @@ public class JobSchedulerManager {
 
     @Inject
     Vertx vertx;
-    private AtomicBoolean enabled = new AtomicBoolean(false);
+    final AtomicBoolean enabled = new AtomicBoolean(false);
+
+    final AtomicLong periodicTimerIdForLoadJobs = new AtomicLong(-1l);
 
     void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupEvent startupEvent) {
-        if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
-            LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
-                    "setting value {} for both",
-                    loadJobIntervalInMinutes,
-                    schedulerChunkInMinutes,
-                    schedulerChunkInMinutes);
-            loadJobIntervalInMinutes = schedulerChunkInMinutes;
+        if (enabled.get()) {

Review Comment:
   done



##########
jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java:
##########
@@ -73,26 +74,49 @@ public class JobSchedulerManager {
 
     @Inject
     Vertx vertx;
-    private AtomicBoolean enabled = new AtomicBoolean(false);
+    final AtomicBoolean enabled = new AtomicBoolean(false);
+
+    final AtomicLong periodicTimerIdForLoadJobs = new AtomicLong(-1l);
 
     void onStartup(@Observes @Priority(Interceptor.Priority.PLATFORM_AFTER) StartupEvent startupEvent) {
-        if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
-            LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
-                    "setting value {} for both",
-                    loadJobIntervalInMinutes,
-                    schedulerChunkInMinutes,
-                    schedulerChunkInMinutes);
-            loadJobIntervalInMinutes = schedulerChunkInMinutes;
+        if (enabled.get()) {
+            startJobsLoadingFromRepositoryTask();
         }
+    }
 
-        //first execution
-        vertx.runOnContext(this::loadJobDetails);
-        //periodic execution
-        vertx.setPeriodic(TimeUnit.MINUTES.toMillis(loadJobIntervalInMinutes), id -> loadJobDetails());
+    private void startJobsLoadingFromRepositoryTask() {
+        //guarantee it starts the task just in case it is not already active
+        if (periodicTimerIdForLoadJobs.get() < 0) {
+            if (loadJobIntervalInMinutes > schedulerChunkInMinutes) {
+                LOGGER.warn("The loadJobIntervalInMinutes ({}) cannot be greater than schedulerChunkInMinutes ({}), " +
+                        "setting value {} for both",
+                        loadJobIntervalInMinutes,
+                        schedulerChunkInMinutes,
+                        schedulerChunkInMinutes);
+                loadJobIntervalInMinutes = schedulerChunkInMinutes;
+            }
+            //first execution
+            vertx.runOnContext(this::loadJobDetails);
+            //next executions to run periodically
+            periodicTimerIdForLoadJobs.set(vertx.setPeriodic(TimeUnit.MINUTES.toMillis(loadJobIntervalInMinutes), id -> loadJobDetails()));
+        }
     }
 
-    protected void onMessagingStatusChange(@Observes MessagingChangeEvent event) {
-        this.enabled.set(event.isEnabled());
+    private void cancelJobsLoadingFromRepositoryTask() {
+        if (periodicTimerIdForLoadJobs.get() > 0) {
+            vertx.cancelTimer(periodicTimerIdForLoadJobs.get());
+            //negative id indicates this is not active anymore
+            periodicTimerIdForLoadJobs.set(-1);
+        }
+    }
+
+    protected synchronized void onMessagingStatusChange(@Observes MessagingChangeEvent event) {

Review Comment:
   done



-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KOGITO-9842] The initial load job task from DB is not executed Job Service [incubator-kie-kogito-apps]

Posted by "kie-ci3 (via GitHub)" <gi...@apache.org>.
kie-ci3 commented on PR #1888:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/1888#issuecomment-1772671663

   
   **PR job** `#1` was: **UNSTABLE**
   Possible explanation: This should be test failures
   
   
   <details>
   <summary><b>Reproducer</b></summary>
   
   
   
   build-chain build full_downstream  -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-apps -u https://github.com/apache/incubator-kie-kogito-apps/pull/1888 --skipParallelCheckout
   
   NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution
   
   </details>
   
   
   Please look here: https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/display/redirect
   
   **Test results:**
   - PASSED: 2738
   - FAILED: 9
   
   Those are the test failures: 
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.index.service.messaging/OracleMessagingKafkaConsumerIT/testProcessInstanceEvent/">org.kie.kogito.index.service.messaging.OracleMessagingKafkaConsumerIT.testProcessInstanceEvent</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.job.http.recipient.test/JobHttpRecipientDevModeTest/writeYourOwnDevModeTest/">org.kie.kogito.job.http.recipient.test.JobHttpRecipientDevModeTest.writeYourOwnDevModeTest</a></summary>
   java.lang.RuntimeException: Unable to start Quarkus test resource class org.kie.kogito.job.http.recipient.test.HttpRecipientResourceMock
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.job.http.recipient.test/JobHttpRecipientTest/___/">org.kie.kogito.job.http.recipient.test.JobHttpRecipientTest.(?)</a></summary>
   java.lang.RuntimeException: Unable to start Quarkus test resource class org.kie.kogito.job.http.recipient.test.HttpRecipientResourceMock
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.messaging/InfinispanMessagingApiTest/cancelJob/">org.kie.kogito.jobs.service.messaging.InfinispanMessagingApiTest.cancelJob</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.messaging.kafka/CloudEventDeserializerTest/deserialize/">org.kie.kogito.jobs.service.messaging.kafka.CloudEventDeserializerTest.deserialize</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.repository.postgresql/PostgreSqlJobRepositoryTest/testFindAll/">org.kie.kogito.jobs.service.repository.postgresql.PostgreSqlJobRepositoryTest.testFindAll</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.resource/KeycloakPostgreSqlJobResourceTest/___/">org.kie.kogito.jobs.service.resource.KeycloakPostgreSqlJobResourceTest.(?)</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.jobs.service.messaging/PostgreSqlMessagingApiTest/cancelJob/">org.kie.kogito.jobs.service.messaging.PostgreSqlMessagingApiTest.cancelJob</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   <details>
   <summary><a href="https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-apps-pr/job/PR-1888/1/testReport/org.kie.kogito.task.console/StaticContentTest/testIndexHtml/">org.kie.kogito.task.console.StaticContentTest.testIndexHtml</a></summary>
   java.lang.RuntimeException: Failed to start quarkus
   </details>
   


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org