LP#1596595 Hold targeter refactoring and optimization.
authorBill Erickson <berickxx@gmail.com>
Tue, 7 Jun 2016 21:32:14 +0000 (17:32 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Fri, 26 May 2017 13:23:07 +0000 (09:23 -0400)
commit55907fec8e56475121de765801e8ff321fb67b22
tree26656780707eb68981a724702429bead848aa972
parent542cf3482e76d2a1f86b4c918bf56546f9cbc990
LP#1596595 Hold targeter refactoring and optimization.

* New open-ils.hold-targeter service

* Ports hold targeter code to a Perl utility function, communicating w/
  the DB via cstore instead of storage.

* Adds a new global flag 'circ.holds.retarget_interval' for configuring
  the hold retarget interval in the database.

* Adds a new DB function to regenerating hold copy maps to make map
  deletion and creation more efficient.

* Adds an option for targeting holds in newest to oldest order.

* Caches all org unit settings per targeter run.

* Adds support for "skip_viable" option.  This tells the hold targeter
  to avoid modifying any holds that target viable copies.  AKA "fix
  broken" mode.

  For example, you might run in skip_viable mode with a retarget
  interval of 24hr once a day to repair non-viable holds, then also run
  the targeter in regular mode once a day with a retarget interval of 48
  hours to give staff 2 days to process viable holds.

* Hold target loops logic changes:

 ** Org units with fewer target attempts are prioritized during loop
    processing.  So, instead of segregating org units into 2 categetories,
    those attempted in the current loop and those not attempted, sort those
    not attempted by the number number of times they have been attempted.
    Within each grouping, prioritize by target weight/proximity as before.

 ** All org units that have been attempted less than the max configured
    amount are on the table for targeting, not just those that have been
    targeted less than the current loop max.  If no orgs with
    less-than-current-max attempts are found, try orgs that match the
    current max (but are still less than the configured max).

 ** When activated, target looping treats the pickup lib like any
    other org unit.  If a targeted copy at the pickup lib remains
    un-captured, at re-target time, a copy at a different branch is
    chosen (if one is available) even if other copies at the pickup
    lib are targetable.

* Parallel targeting support baked into service.

  Teach the targeter to process a subset of holds based on the number of
  parallel targeters at play and the parallel targeting slot each targeter
  instance occupies.

  As with the existing hold targeter, group holds by their metarecord to
  avoid multiple targeter processes targeting the same sets of potential
  copies.

* Logging / code refactoring and clean up.

* New hold_targeter_v2.pl script for batch hold targeting.  Existing
  targeter remains for backwards-compat.

hold_targeter_v2.pl options:

--verbose
    Print process counts

--parallel <parallel-process-count>
    Number of parallel hold processors to run.  This overrides any
    value found in opensrf.xml

--target-all
    Target all active holds, regardless of when they were last targeted.

--skip-viable
    Avoid modifying holds that currently target viable copies.
    In other words, only (re)target holds in a non-viable state.

--retarget-interval
    Override the 'circ.holds.retarget_interval' global_flag value.

--parallel-init-sleep
    Time to wait between starting each parallel instance.  Useful for
    avoiding dog-piling the DB.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold_targeter.sql [new file with mode: 0644]