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

feat: include most recent job progress in post condition error message [DHIS2-18751] #19621

Merged
merged 7 commits into from
Jan 9, 2025

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Jan 8, 2025

Summary

While the plan was just to add a better post-condition logging I found that executing jobs manually was broken and so I did the post spring 6 cleanup in this context as well.

Post-condition Logging

  • added the last process, stage and item description to the exception message
  • added a new failWithPostCondition flag to the TEST job so a post-condition failure could be simulated

Scheduling with Spring 6

  • remove the quasi duplicate code path added during spring 6 migration
  • removed the test vs prod "helper" workaround (it was identical at this point)
  • added a new service JobExecutionService for the execution of one-off jobs to have a layer for right TX handling
  • use getByUidNoAcl whenever a job is loaded within the scheduling so make sure ACL isn't in the way
  • initialize the lastAlive counter with zero so the first update happens immediately giving faster feedback for the observer that the job is actually running
  • replaced getSingleResult() with either getSingleResult(Query) or getResultStream().findFirst().orElse(null)
  • removed the NotFoundException from being thrown when calling executeOnceNow (one-off jobs)

Automatic Testing

There are plenty of tests covering scheduling. Also once must check that the e2e tests run in about 10-15min not 90min.

Manual Testing

  • Create a job of type TEST
  • set the failWithPostCondition to true
  • run the job manually or wait for its scheduled time to occur
  • check the logs for the exception

Example:

java.util.concurrent.CancellationException: Non-null post-condition failed after: Test job
  => Stage 1
	at org.hisp.dhis.scheduling.RecordingJobProgress.cancellationException(RecordingJobProgress.java:217) ~[classes/:?]
	at org.hisp.dhis.scheduling.RecordingJobProgress.nonNullStagePostCondition(RecordingJobProgress.java:307) ~[classes/:?]

@jbee jbee self-assigned this Jan 8, 2025
Copy link

sonarqubecloud bot commented Jan 9, 2025

@jbee jbee marked this pull request as ready for review January 9, 2025 11:24
Copy link
Contributor

@david-mackessy david-mackessy left a comment

Choose a reason for hiding this comment

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

this should be very helpful 👍

@jbee jbee merged commit 0cb4005 into master Jan 9, 2025
17 checks passed
@jbee jbee deleted the DHIS2-18751 branch January 9, 2025 13:53
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.

3 participants