[Bug 44250] New: MARC batch import skips indexing records committed before an error
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 Bug ID: 44250 Summary: MARC batch import skips indexing records committed before an error Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: MARC Bibliographic record staging/import Assignee: nugged@gmail.com Reporter: nugged@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- When a staged MARC batch import stops on an error, bibliographic records saved earlier in the batch can be present in the catalogue database without an indexing job. The importer commits records individually and queues indexing once at the end. An exception on a later record exits before that queue call. For example, records A, B and C commit successfully, then D throws during import. D does not commit and the batch remains staged. A, B and C are still in the catalogue, with no indexing job from this import. The patch collects bibliographic IDs after their database commit. On a caught error, it rolls back the open transaction, queues one normal indexing request for the records already committed, and propagates the original error. The successful path still queues one complete batch. A process that is terminated before error handling can run still needs operator reindexing. Verification on main: the automated regression runs the real importer against DBIx::Class and SQLite, with a second connection confirming the commits and a mock recording the indexing call. Before the fix there is no indexing call after D fails. Afterward there is exactly one call for A, B and C. Koha QA passed. A manual staff-interface and Elasticsearch run remains outstanding. Bug 43028 is related through the same import loop. It isolates undecodable records. This report covers indexing records already committed when the import aborts. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 Andrii Nugged <nugged@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=43028 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 --- Comment #1 from Andrii Nugged <nugged@gmail.com> --- Created attachment 212489 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212489&action=edit Bug 44250: Index committed records after a MARC import error -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 --- Comment #2 from Andrii Nugged <nugged@gmail.com> --- Created attachment 212660 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212660&action=edit Bug 44250: Index committed records after a MARC import error BatchCommitRecords commits each record separately and queues one index update when the batch completes. If a later record throws, the earlier records remain in the catalogue database but never reach the index. Staff cannot find those records through catalogue search. Collect bibliographic IDs after each successful commit. On an exception, roll back the current record and queue one normal index update for the committed IDs. Rethrow the original exception so the import job still reports the failure. Leave the batch staged. Skip previously imported rows before opening a transaction. The importer now owns rollback, so the staff job can record the failure without rolling back again. Test plan: Use a disposable MARC21 Koha with Elasticsearch and the workers running. Set up the MARC files and the test-only failure fixture from the accompanying fixture archive. It rejects the fourth commit for the two failure batches. Before applying the patch: 1. Open Cataloging > Stage records for import. 2. Choose bug44250-baseline.xml. 3. Click Upload file. 4. Set Format to MARCXML. 5. Click Stage for import. 6. Open View batch. 7. Click Import this batch into the catalog. 8. Open View detail of the enqueued job. Wait for it to fail. 9. Return to the staged batch. Open the catalogue links of the three imported records. 10. Enter Indexprobe44250Baseline in Search catalog. Expected before the patch: no matching search results. Apply the patch. After applying the patch: 1. Repeat the same steps with bug44250-patched.xml. 2. Verify the import still fails and the staged batch still has three committed records. 3. Enter Indexprobe44250Patched in Search catalog. Three records should appear after the indexing job finishes. 4. Repeat with bug44250-control.xml. All four records should appear in a search for Indexprobe44250Control. Automated regression: prove -I. t/ImportBatchIndexing.t Co-Authored-By: Loontik <loontik@nugged.team> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 Andrii Nugged <nugged@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #212489|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 --- Comment #3 from Andrii Nugged <nugged@gmail.com> --- Created attachment 212661 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212661&action=edit Bug 44250 MARC21 test fixtures -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44250 Andrii Nugged <nugged@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org