Bug 18185

Summary: Clears loan history
Product: Koha Reporter: Fred <freddyguerr>
Component: CirculationAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: critical    
Priority: P5 - low CC: freddyguerr, gmcharlt, jonathan.druart, jschmidt, kyle.m.hall, ricvargasmed
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18003
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18242
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Chronology of error
Bug 18185: [SOLUTION 1]DB changes - remove PK on old_issues.issue_id
Bug 18185: [SOLUTION 1]Schema changes
Bug 18185: [SOLUTION 1]Remove primary key on old_issues.issue_id

Description Fred 2017-03-01 03:30:15 UTC
When returning an item and reviewing the loan history, it does not appear in the loan history, I use koha v. 16.11, Debian 8.
Comment 1 Fred 2017-03-01 04:09:39 UTC
Created attachment 60749 [details]
Chronology of error

Chronology of error in image
Comment 2 Jonathan Druart 2017-03-01 08:30:19 UTC
Something in the logs?
Comment 3 Fred 2017-03-03 03:42:24 UTC
(In reply to Jonathan Druart from comment #2)
> Something in the logs?

In the log you do not see any errors
Comment 4 Ricardo Vargas 2017-03-04 16:51:16 UTC
To reproduce this error I did the following.
- Provide a copy to a user
- Check movement history
- All loans that the user has
- Return the sample
- Check movement history
- The user loans will be displayed, without the last one returned

Note: sometimes I save the returns, but the 3 exercises reproduced the error.

Tested on Koha 16.05 and 16.11 installed by packages in Debian 8 and Ubuntu 16.04 LTS
Comment 5 Jonathan Druart 2017-03-07 14:32:56 UTC
Ricardo, I cannot recreate on 16.11.04 (using MariaDB).
Can you confirm that you are not using MySQL in strict mode?
See https://wiki.koha-community.org/wiki/Koha_on_ubuntu_-_packages#Ubuntu_16.04_and_MySQL_5.7
Comment 6 Fred 2017-03-08 23:46:23 UTC
Change from mysql to mariaDB without success, the error is maintained, I have Debian 8
Comment 7 Fred 2017-03-08 23:48:17 UTC
mysql Ver 15.1 Distrib 10.0.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Server version: Apache/2.4.10 (Debian)
Comment 8 Jonathan Druart 2017-03-09 14:43:24 UTC
Can you provide a screencast?
Comment 9 Ricardo Vargas 2017-03-09 15:38:29 UTC
This is the screencast.

http://autode.sk/2na3tNf
Comment 10 Jonathan Druart 2017-03-09 16:59:23 UTC
I think you face the same problem as bug 18003, but for issues.

To confirm it, try:
1. Issue an item for a patron, note the itemnumber of this item
2. Get the issue id of this issue:
  SELECT issue_id FROM issues WHERE itemnumber=ITEMNUMBER;
If you do not know the item number, you can get it from the barcode with:
  SELECT itemnumber FROM items where barcode="BARCODE";

Then check if this issue_id already exists in the old_issues table:
  SELECT COUNT(*) FROM old_issues WHERE issue_id=ISSUE_ID
Comment 11 Jonathan Druart 2017-03-09 18:52:49 UTC
See also bug 18242.
Comment 12 Jonathan Druart 2017-03-09 19:00:53 UTC Comment hidden (obsolete)
Comment 13 Jonathan Druart 2017-03-09 19:00:58 UTC Comment hidden (obsolete)
Comment 14 Jonathan Druart 2017-03-09 19:01:04 UTC Comment hidden (obsolete)
Comment 15 J Schmidt 2017-03-10 21:24:08 UTC
Can I ask what is the starting Koha version that's impacted by this bug? 16.05 or earlier? 16.11? thank you.
Comment 16 Jonathan Druart 2017-03-10 21:46:26 UTC
(In reply to J Schmidt from comment #15)
> Can I ask what is the starting Koha version that's impacted by this bug?
> 16.05 or earlier? 16.11? thank you.

This bug impacts all Koha versions, but only in very specific cases.
Basically it happens if you restart the DBMS and that the last item that has been checked out is checked in. In that case the auto increment value of the issue table become lower than the max value of old_issues.issue_id
After the restart, the next issue will get an issue_id that already exists in the old_issues table. When this issue will be checked in and moved to the old_issue table, the copy of the data to the old_issues table will fail and the row will be deleted from the issues table => data are lost!
Comment 17 Jonathan Druart 2017-03-15 19:48:47 UTC
Marked as a duplicate of bug 18242, please reopen if it does not fix your issue.

*** This bug has been marked as a duplicate of bug 18242 ***