Bug 41248 - Add ability for real time holds queue background jobs to skip duplicate jobs
Summary: Add ability for real time holds queue background jobs to skip duplicate jobs
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: 25.05
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall (khall)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-13 14:39 UTC by Kyle M Hall (khall)
Modified: 2025-11-15 20:38 UTC (History)
0 users

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 41248: Add ability for real time holds queue background jobs to skip duplicate jobs (edit) (1.74 KB, patch)
2025-11-13 15:29 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41248: Add unit tests (1.78 KB, patch)
2025-11-13 15:36 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41248: Add ability for real time holds queue background jobs to skip duplicate jobs (1.73 KB, patch)
2025-11-13 15:37 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41248: Add unit tests (1.78 KB, patch)
2025-11-13 15:37 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41248: Add ability for real time holds queue background jobs to skip duplicate jobs (1.77 KB, patch)
2025-11-13 18:41 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 41248: Add unit tests (1.81 KB, patch)
2025-11-13 18:41 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 41248: Add index on background_jobs.data (2.16 KB, patch)
2025-11-14 11:38 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 41248: Add index on background_jobs.data (2.16 KB, patch)
2025-11-14 11:39 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2025-11-13 14:39:33 UTC
It seems inefficient to rebuild the holds queue repeatedly for the same record. We should skip enqueuing BatchUpdateBiblioHoldsQueue jobs if there is already a queued job that hasn't started.
Comment 1 Kyle M Hall (khall) 2025-11-13 15:29:01 UTC
Created attachment 189567 [details] [review]
Bug 41248: Add ability for real time holds queue background jobs to skip duplicate jobs (edit)

It seems inefficient to rebuild the holds queue repeatedly for the same record. We should skip enqueuing BatchUpdateBiblioHoldsQueue jobs if there is already a queued job that hasn't started.
Test Plan:
1) Enable real time holds queue
2) Ensure the default queue background job worker is not running
3) Set up 2 or more holds for the record
4) Alter the priority for those holds a couple times
5) Confirm only one new job is in the background_jobs table for that
   record.
Comment 2 Kyle M Hall (khall) 2025-11-13 15:29:02 UTC
It seems inefficient to rebuild the holds queue repeatedly for the same record. We should skip enqueuing BatchUpdateBiblioHoldsQueue jobs if there is already a queued job that hasn't started.
Test Plan:
1) Enable real time holds queue
2) Ensure the default queue background job worker is not running
3) Set up 2 or more holds for the record
4) Alter the priority for those holds a couple times
5) Confirm only one new job is in the background_jobs table for that
   record.
Comment 3 Kyle M Hall (khall) 2025-11-13 15:36:24 UTC
Created attachment 189569 [details] [review]
Bug 41248: Add unit tests
Comment 4 Kyle M Hall (khall) 2025-11-13 15:37:13 UTC
Created attachment 189570 [details] [review]
Bug 41248: Add ability for real time holds queue background jobs to skip duplicate jobs

It seems inefficient to rebuild the holds queue repeatedly for the same record. We should skip enqueuing BatchUpdateBiblioHoldsQueue jobs if there is already a queued job that hasn't started.
Test Plan:
1) Enable real time holds queue
2) Ensure the default queue background job worker is not running
3) Set up 2 or more holds for the record
4) Alter the priority for those holds a couple times
5) Confirm only one new job is in the background_jobs table for that
   record.
Comment 5 Kyle M Hall (khall) 2025-11-13 15:37:14 UTC
Created attachment 189571 [details] [review]
Bug 41248: Add unit tests

Patch from commit fadb037
Comment 6 Kyle M Hall (khall) 2025-11-13 15:37:16 UTC
It seems inefficient to rebuild the holds queue repeatedly for the same record. We should skip enqueuing BatchUpdateBiblioHoldsQueue jobs if there is already a queued job that hasn't started.
Test Plan:
1) Enable real time holds queue
2) Ensure the default queue background job worker is not running
3) Set up 2 or more holds for the record
4) Alter the priority for those holds a couple times
5) Confirm only one new job is in the background_jobs table for that
   record.
Comment 7 Lucas Gass (lukeg) 2025-11-13 18:41:43 UTC
Created attachment 189581 [details] [review]
Bug 41248: Add ability for real time holds queue background jobs to skip duplicate jobs

It seems inefficient to rebuild the holds queue repeatedly for the same record. We should skip enqueuing BatchUpdateBiblioHoldsQueue jobs if there is already a queued job that hasn't started.

Test Plan:
1) Enable real time holds queue
2) Ensure the default queue background job worker is not running
3) Set up 2 or more holds for the record
4) Alter the priority for those holds a couple times
5) Confirm only one new job is in the background_jobs table for that
   record.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Lucas Gass (lukeg) 2025-11-13 18:41:45 UTC
Created attachment 189582 [details] [review]
Bug 41248: Add unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 9 Kyle M Hall (khall) 2025-11-13 19:52:44 UTC
Failing QA until supply a follow-up patch to add an index to background_jobs.data. On a server with 762052 background_jobs entries, the queries take over 1.5 seconds each, which seems like a long time to me.
Comment 10 Kyle M Hall (khall) 2025-11-14 11:38:20 UTC
Created attachment 189593 [details] [review]
Bug 41248: Add index on background_jobs.data

Index decreases search result time from 1.6 seconds to 0.001 seconds on 153,205 rows

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Kyle M Hall (khall) 2025-11-14 11:39:27 UTC
Created attachment 189594 [details] [review]
Bug 41248: Add index on background_jobs.data

Index decreases search result time from 1.6 seconds to 0.001 seconds on 153,205 rows

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>