In multi tenant environment FolioExecutionContext is initialized with a new tenant id every time a new job is created from the different tenant. Sometimes, if job launches with async mode, FolioExecutionContext is initialized with tenant id other than id of the tenant this job comes from. It causes a try to update a job that does not exist in this tenant.
Steps to Reproduce:
- Go to Circulation log and apply filter for Loan to have at least a couple of records (for example, Checked out).
- Create another tenant and do Step 1 under user from the new tenant.
- Go to Actions -> Export results (CSV).
- Repeat Step3 at least 20 times and wait for the completion of all jobs.
- Go to Export manager and you may see that a couple of jobs have SCHEDULED status.
- Retrieve logs for mod-data-export-spring and you may see ERROR mentioned in the Description of this bug.
- Retrieve logs for mod-data-export-worker and you may see the following ERROR:
No mentioned errors in the log, no jobs with SCHEDULED status in multi tenant cluster.
Jobs are getting stuck with SCHEDULED status, errors in the log.
This bug appears only in multi tenant environment and can be reproduced on testing as well.