Bug 37147

Summary: If the MARC import chokes on bad record, it does not fail background job or import
Product: Koha Reporter: David Cook <dcook>
Component: MARC Bibliographic record staging/importAssignee: Bugs List <koha-bugs>
Status: RESOLVED INVALID QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 27421    
Bug Blocks:    

Description David Cook 2024-06-21 02:56:49 UTC
I've had a library accidentally try to import a record with bad data, and the MARC import is silently stopping. 

The background job stays stuck as "Started" and the batch stays stuck as "Staged".

Glancing at the code... it looks like it should work. Going to spend a couple minutes trying to figure this one out...
Comment 1 David Cook 2024-06-21 03:28:26 UTC
This is so bizarre...

I've added all this debugging code, and according to the code it is updating... but it's not actually updating the database.

It looks a lot like a transaction related issue... but DBIx::Class's transaction handling leaves a lot to be desired...
Comment 2 David Cook 2024-06-21 04:02:02 UTC
Tricky trying to reproduce the scenario. Haven't yet received the real MARC file with the problem, and my attempts to re-create one yield either a MARC file that succeeds or fails to stage...
Comment 3 David Cook 2024-06-21 04:14:55 UTC
Interestingly it seems easier to sneak bad bytes into Koha through MARC records rather than MARCXML records... especially when you provide multiple records with some of the records being 100% OK.
Comment 4 David Cook 2024-06-21 06:29:39 UTC
I've got the file, and tried it again in my dev environment, which should be pretty much the same as the backup system it's not working on... but in local dev the background job is correctly marked as "Failed", although the batch is still marked as "Staged" instead of failed...
Comment 5 David Cook 2024-06-28 03:47:24 UTC
I can't reproduce this now so going to close it for now...