Skip to content
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

fix: run continuous jobs immediately [DHIS2-15276] #15630

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Nov 8, 2023

The issue is that during tests when a test e.g. performs an import the actual import is just some milliseconds. But the first import would execute synchronous with the 20sec scheduler loop. So it is done shortly after the loop started to run. The queue would be empty again as the next test is waiting for the previous one to finish which requires finishing the import. So the next test runs again shortly after the loop cycle started, it then adds its import but at that point since the queue was empty the delay of almost 20 seconds has to be "payed" again essentially causing each test that has an import to take 20 seconds which causes overall execution time of the e2e tests go from 15min to 2h.

To prevent this test issue the continuous jobs are directly added to the queue and also will spawn a worker if no queue was present (and worked) at that time. This should remove the 20 second delay for this type of jobs. The cost is that now there is a concurrent part in the scheduler where both the scheduling loop thread and async web worker threads from executeNow will add to the queue and potentially spawn worker.

As the accidental spawning of more than one worker is no issue this does not need to be synchronized the hard way.

@jbee jbee self-assigned this Nov 8, 2023
Copy link

sonarqubecloud bot commented Nov 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Merging #15630 (8278d6c) into master (1a07024) will decrease coverage by 0.01%.
Report is 3 commits behind head on master.
The diff coverage is 6.66%.

@@             Coverage Diff              @@
##             master   #15630      +/-   ##
============================================
- Coverage     66.19%   66.19%   -0.01%     
+ Complexity    31256    31253       -3     
============================================
  Files          3487     3487              
  Lines        129879   129887       +8     
  Branches      15166    15170       +4     
============================================
- Hits          85979    85975       -4     
- Misses        36814    36824      +10     
- Partials       7086     7088       +2     
Flag Coverage Δ
integration 49.77% <6.66%> (-0.01%) ⬇️
integration-h2 32.40% <0.00%> (-0.01%) ⬇️
unit 30.31% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...sp/dhis/scheduling/DefaultJobSchedulerService.java 10.41% <20.00%> (+1.11%) ⬆️
...in/java/org/hisp/dhis/scheduling/JobScheduler.java 20.00% <0.00%> (-0.66%) ⬇️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5086fe...8278d6c. Read the comment docs.

@jbee jbee enabled auto-merge (squash) November 9, 2023 16:26
@jbee jbee requested a review from enricocolasante November 9, 2023 17:26
@jbee jbee merged commit ae674bb into dhis2:master Nov 10, 2023
18 checks passed
void runIfDue(JobConfiguration config);

/**
* Manually runs a job. OBS! This bypasses any actual checking if the job is due to run. When this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does OBS stand for? seeing it in the code a good bit and have no idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OBS! is how you say "oops" in Sweden and I think Norway as well. Here it is often used to catch the eye to say: pay attention. I thought it is more international but maybe not. Maybe use the English form? Oops?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh ok. Sounds like the English alternative to 'N.B.' (which is a Latin acronym 😄). Now that I know, it's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants