Closed KernelCrap closed 11 months ago
I didn't dig deep yet, but it appears that the issue is in version 1.20.2 and it's my fault. There is no signal of new jobs after the transaction has been committed.
I've made draft PR https://github.com/hangfire-postgres/Hangfire.PostgreSql/pull/332
The example code runs as expected, jobs execute immediately.
[2023-10-18T12:42:06.9614230Z]: TransactionScope: Started
[2023-10-18T12:42:07.1539390Z]: TransactionScope: Completed
[2023-10-18T12:42:07.1576300Z]: TransactionScope: Disposed. Waiting 5 seconds...
[2023-10-18T12:42:07.2001600Z]: Hangfire task: Started #3
[2023-10-18T12:42:07.2001970Z]: Hangfire task: Started #2
[2023-10-18T12:42:07.2246870Z]: Hangfire task: Completed #3
[2023-10-18T12:42:07.2246890Z]: Hangfire task: Completed #2
[2023-10-18T12:42:12.2758860Z]: Items:
- Item: 1 - A
- Item: 3 - B
- Item: 2 - B
I haven't checked it properly yet, unfortunately I don't have time right now. If someone could check, I would appreciate it. Sorry for bug.
I don't think there's anything else to check. Code looks fine, tests are green, your own test shows the expected behavior like it was before the issue started.
Unless you have some extra stuff planned for your draft, I'd say we merge it and publish.
I will check the case with several workers now, because of which I initially made the changes.
@azygis , quick tests in my multi-worker, multi-queue environment were successful as well: jobs executed immediately, and the count of fetching queries did not increase.
I've removed the Draft label.
@Tinyakov thanks for super quick resolution!
Enqueuing a job inside a transaction scope no longer runs as expected after updating from 1.20.1 to 1.20.2.
It might be related to the following change: Fixing Enqueued Job Trigger for Multiple Queues
Runnable example code:
Output with Hangfire.PostgreSql 1.20.2:
Output with Hangfire.PostgreSql 1.20.1 (runs as expected):