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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to