[Koha-bugs] [Bug 22437] New: Subsequent authority merges in cron cause biblios to lose authority information

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Feb 28 17:53:32 CET 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22437

            Bug ID: 22437
           Summary: Subsequent authority merges in cron cause biblios to
                    lose authority information
 Change sponsored?: ---
           Product: Koha
           Version: 18.11
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P5 - low
         Component: MARC Authority data support
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: pjamorim91 at gmail.com
        QA Contact: testopia at bugs.koha-community.org
  Target Milestone: ---

Here's how to reproduce the problem:
AuthorityMergeLimit syspref is default 50. 
Here's an example list of 3 authorities (A, B and C) that should be merged
together - resulting in 1 authority - and the total count of biblios linked to
each respective authority (similar to the interface you get when searching
authorities):

A       100
B       60
C       2

The good scenario:
If you merge the authorities like this:
First: C -> A
Second: B -> A

All is good, after the first merge (C -> A), A has 102 biblios. 
After second merge (B -> A), B no longer exists and A still has 102 - as
expected, because the merge is scheduled to the cron.
After forcing the cron koha-foreach --chdir --enabled
/usr/share/koha/bin/cronjobs/merge_authorities.pl -b -v authority A now has 162
biblios, as expected.

The bad scenario:
The problem occurs if authorities are merged like this:
First: C -> B
Second: B -> A

After the first merge (C -> B), B has 62 biblios. 
After the second merge (B -> A), B no longer exists and A still has 100 - as
expected, because the merge is scheduled to the cron.
However, after forcing the cron koha-foreach --chdir --enabled
/usr/share/koha/bin/cronjobs/merge_authorities.pl -b -v authority A still has
100 biblios, and the 62 biblios that were previously linked to B have
effectively lost the authority information they previously had.

After some testing, I noticed that Koha will schedule an authority merge for
the same authority (on itself), even when the biblios count doesn't surpass
AuthorityMergeLimit, I'll explain:
For the C -> B merge, the 2 biblios from C will be updated immediately in the
application (because 2 < 50), but simultaneously Koha will schedule the cron
merge B -> B.
I think this happens because the merge.pl script first modifies the reference
authority using ModAuthority (that calls the merge function), and then calls
the merge function, can be seen here:
https://github.com/Koha-Community/Koha/blob/18.11.x/authorities/merge.pl#L79

Which means that Koha will run the merge function, twice, for each authority
merge made in the application.
I think this is by design, because if B gets modified, Koha will have to update
60 biblios with the new authority information, updated subfields information
etc, and this should be indeed postponed to the cron, hence the merge on itself
B -> B caused by ModAuthority.
However, because B -> A happened (deleting B) after C -> B and before the cron
had the chance to run, by the time the cron has to run B -> B, B has already
been deleted, cleaning the authority information from the 60 (or 62) biblio
records.

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list