Koha/circ
Jonathan Druart a9a500e81d Bug 18966: Do not deal with duplicate issue_id on checkin
Koha suffers of big bugs due to its history: When data are deleted, they
are moved to another tables.
For instance issues and old_issues: when a checkin is done, it is moved
to the old_issues table.
That leads to a main problem that is described on
https://wiki.koha-community.org/wiki/DBMS_auto_increment_fix

However we tried first to fix the problem (for issues/old_issues) at
code level on bug 18242.
The goal was to prevent data lost.
Data lost may happens in this case:
Check an item out (issue_id = 1)
Check an item in (issue_id = 1)
Restart MySQL (reset auto increment for issue_id to 1)
Check an item out (issue_id = 1)
Check an item in => BOOM, the issue_id is a PK in old_issues and the
move fails.
Before bug 18242 the data were lost, we inserted the value into
old_issues, which fails silently (because of RaiseError set to 0 in
Koha::Database), then delete the row from issues.
That has been fixed using a transaction.

This patch introduced a regression we tried to fix on bug 18651 comment
0, the patron was charged even if the checkin was rejected.
A good way to fix that would have been to LOCK the tables:
1- Start a transaction
2- LOCK the table to make sure nobody will read id and avoid race
   conditions
3- Move the content from one table to the other, dealing with ids
4- UNLOCK the table
5- Commit the transaction
But there were problems using LOCK and DBIx::Class (See commit
905572910b - Do no LOCK/UNLOCK the table).

Finally the solution implemented is not acceptable for several reasons:
- batch checkins may fail
- issue_id will always stay out of sync (between issues and old_issues)
See 18651 comment 66.

Since the next stable releases are very soon, and we absolutely need to
fix this problem, I am suggesting to:
1- Execute the move in a transaction to avoid data lost and reject the
   checkin if we face IDs dup
=> It will only reject 1 checkin (max is 1 * MySQL restart), no need to
   deal with race conditions,
2- Display a warning on the checkin page and link to a
   solution/explanation
3- Communicate as much as we can on the proper fix: Update auto
   increment values when the DBMS is restarted -
    https://wiki.koha-community.org/wiki/DBMS_auto_increment_fix
4- Display a warning on the about page for corrupted data (see bug
   18931)
5- Write and make available a maintenance script to fix corrupted data
   (TODO LATER)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-07-26 13:50:57 -03:00
..
add_message.pl Bug 3669: Remove parameters passed to action of form 2016-06-24 13:20:14 +00:00
article-request-slip.pl Bug 17762: Send lang to GetPreparedLetter 2017-05-09 20:56:41 +00:00
article-requests.pl Bug 14610 - Add and update scripts 2016-10-26 12:15:14 +00:00
bookcount.pl Bug 15758: Koha::Libraries - Remove GetBranches 2016-09-08 14:36:03 +00:00
branchoverdues.pl Bug 16530: Add a new method to the Branches TT Plugin to avoid c/p 2017-03-03 18:34:36 +00:00
branchtransfers.pl Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
circulation-home.pl Bug 16530: Add a new method to the Branches TT Plugin to avoid c/p 2017-03-03 18:34:36 +00:00
circulation.pl Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
del_message.pl Bug 15632: Koha::Patron::Messages - Remove DeleteMessage 2016-03-03 21:22:13 +00:00
hold-transfer-slip.pl Bug 13482: Prevent race condition on printing a ReserveSlip 2015-04-22 16:32:15 -03:00
offline-mf.pl Bug 11944: use CGI( -utf8 ) everywhere 2015-01-13 13:07:21 -03:00
offline.pl Bug 11944: use CGI( -utf8 ) everywhere 2015-01-13 13:07:21 -03:00
on-site_checkouts.pl Bug 16530: Add a new method to the Branches TT Plugin to avoid c/p 2017-03-03 18:34:36 +00:00
overdue.pl Bug 8548: Add datatable to circ overdue report, remove sortby filter 2017-03-31 12:35:47 +00:00
pendingreserves.pl Bug 18079: Holds to pull cleanup 2017-02-14 13:48:34 +00:00
renew.pl Bug 16530: Add a new method to the Branches TT Plugin to avoid c/p 2017-03-03 18:34:36 +00:00
request-article.pl Bug 14610 - Add and update scripts 2016-10-26 12:15:14 +00:00
reserveratios.pl Bug 15672: (follow-up) Show descriptions instead of codes on the hold ratios report 2016-03-23 21:07:04 +00:00
returns.pl Bug 18966: Do not deal with duplicate issue_id on checkin 2017-07-26 13:50:57 -03:00
selectbranchprinter.pl Bug 16530: Add a new method to the Branches TT Plugin to avoid c/p 2017-03-03 18:34:36 +00:00
transfer-slip.pl Bug 9978: Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:38 -03:00
transferstoreceive.pl Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
view_holdsqueue.pl Bug 18881: [QA Follow-up] Remove even more 2017-07-06 14:29:04 -03:00
waitingreserves.pl Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
ypattrodue-attr-search-authvalue.pl Bug 9978: (followup) Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:43 -03:00
ysearch.pl Bug 15548: Move new patron related code to Patron* 2016-03-03 14:38:26 -07:00