Koha/C4
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
..
AuthoritiesMarc
Barcodes
ClassSortRoutine
Creators Bug 14143 - Patron cards: Crash (confusion between table names creator_templates and club_template_enrollment_fields) 2017-04-28 08:39:41 -04:00
External
Form
Heading
ILSDI Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
Installer Bug 17190 - Marked REST API as mandatory (require = 1) in PerlDependencies.pm 2017-05-08 09:06:30 -04:00
Labels
Linker
Members Bug 17825: (followup) Remove unused function AttributeTypeExists 2017-03-31 14:37:21 +00:00
OAI Bug 18601: OAI/Sets.t mangles data due to truncate in ModOAISetsBiblios 2017-06-13 16:18:59 -03:00
Output
Patroncards Bug 18244: Patron card creator does not take in account fields with underscore (B_address etc.) 2017-03-31 12:46:28 +00:00
Reports Bug 17898: Automagically convert SQL reports 2017-05-19 18:48:26 +00:00
Search
Serials
SIP Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
Utils Bug 18094: Only search in searchable patron attributes if searching in standard fields 2017-03-22 21:12:43 +00:00
Accounts.pm Bug 18584: Fix trailing spaces in C4/Accounts.pm 2017-06-12 17:57:20 -03:00
Acquisition.pm Bug 18262: Koha::Biblio - Remove GetBiblioData - part 1 2017-07-14 12:22:23 -03:00
Auth.pm Bug 18880: [QA Follow-up] Finishing touch 2017-07-14 12:05:31 -03:00
Auth_cas_servers.yaml.sample
Auth_with_cas.pm
Auth_with_ldap.pm Bug 14625 - LDAP: skip extended patron attributes in 'borrowers' attribute update 2017-05-19 09:52:05 -04:00
Auth_with_shibboleth.pm Bug 12026: [QA Follow-up] Fix a POD line 2017-03-31 14:28:18 +00:00
AuthoritiesMarc.pm Bug 18854: Protect few other occurrences of offset 2017-07-14 12:02:04 -03:00
BackgroundJob.pm
Barcodes.pm
Biblio.pm Bug 18262: Koha::Biblio - Remove GetBiblioData - part 1 2017-07-14 12:22:23 -03:00
Bookseller.pm Bug 14535: Update the supplier filter too 2017-03-31 12:38:44 +00:00
Boolean.pm
Breeding.pm
Budgets.pm Bug 18942: Simplify syntax 2017-07-17 15:52:01 -03:00
Calendar.pm Bug 14572 - insert_single_holiday() forces a value on an AUTO_INCREMENT column, during an INSERT 2017-07-06 14:29:04 -03:00
Charset.pm Bug 18152 : fix unimarc label in SetMarcUnicodeFlag 2017-05-08 08:36:57 -04:00
Circulation.pm Bug 18966: Do not deal with duplicate issue_id on checkin 2017-07-26 13:50:57 -03:00
ClassSortRoutine.pm
ClassSource.pm Bug 17208: Checking if classification source or filing rule already exists before adding 2016-12-23 11:33:48 +00:00
Context.pm Bug 18771: CGI.pm: Subroutine multi_param redefined 2017-07-06 14:29:03 -03:00
Contract.pm
CourseReserves.pm Bug 18276: Remove GetBiblioFromItemNumber - Course reserves 2017-07-10 12:09:24 -03:00
Creators.pm
Debug.pm
Heading.pm
HoldsQueue.pm Bug 18605: Remove TRUNCATE from C4/HoldsQueue.pm 2017-07-24 14:12:27 -03:00
HTML5Media.pm Bug 17501: Remove Koha::Upload::get from Koha::Upload 2017-01-20 14:20:05 +00:00
Images.pm
ImportBatch.pm Bug 18260: Koha::Biblio - Remove GetBiblio 2017-07-10 13:03:38 -03:00
ImportExportFramework.pm
InstallAuth.pm Bug 18578: Use subdirectory in /tmp for session storage during installation 2017-05-19 10:46:37 -04:00
Installer.pm Bug 18215: Fix another tls warning 2017-03-22 21:00:41 +00:00
ItemCirculationAlertPreference.pm
Items.pm Bug 18277: [QA Follow-up] Additional polishing 2017-07-10 13:03:38 -03:00
Koha.pm Bug 17843: Remove C4::Koha::getitemtypeinfo 2017-07-05 13:42:21 -03:00
Labels.pm
Languages.pm
Letters.pm Bug 18613: Remove letter rule correctly as superlibrarian 2017-07-17 12:41:32 -03:00
Linker.pm
Log.pm
MarcModificationTemplates.pm
Matcher.pm Bug 17710 - C4::Matcher::get_matches and C4::ImportBatch::GetBestRecordMatch should use same logic 2017-06-15 15:27:46 -03:00
Members.pm Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
Message.pm
NewsChannels.pm Bug 17762: Fix test for NewsChannels.t 2017-05-09 20:56:42 +00:00
Output.pm
Overdues.pm Bug 17975: Let C4::Letters manage today param substitution 2017-06-15 15:56:00 -03:00
Patroncards.pm
Print.pm
Record.pm Bug 18277: Remove GetBiblionumberFromItemnumber - Easy ones 2017-07-10 13:03:37 -03:00
Reports.pm
Reserves.pm Bug 18262: Koha::Biblio - Remove GetBiblioData - part 1 2017-07-14 12:22:23 -03:00
Ris.pm
RotatingCollections.pm
Scheduler.pm
Scrubber.pm
Search.pm Bug 18854: Make sure offset will not be < 0 - protect from DoS 2017-07-14 12:02:04 -03:00
Serials.pm Bug 18260: Koha::Biblio - Remove GetBiblio 2017-07-10 13:03:38 -03:00
Service.pm Bug 7550: [QA Follow-up] Resolve param warning from sco-patron-image 2017-05-08 09:00:26 -04:00
ShelfBrowser.pm
SMS.pm Bug 18732: Noisy t/SMS.t triggered by koha_conf.xml without sms_send_config 2017-06-15 15:27:46 -03:00
SocialData.pm
Stats.pm
Suggestions.pm Bug 17762: Send lang to GetPreparedLetter 2017-05-09 20:56:41 +00:00
Tags.pm
Templates.pm Bug 18010: Remove potential exposure from gettemplate 2017-03-23 00:36:12 +00:00
TmplToken.pm
TmplTokenType.pm
TTParser.pm
UsageStats.pm Bug 9988: Remove further references to dontmerge 2017-04-13 08:53:47 -04:00
XISBN.pm Bug 18262: Fix C4::XISBN 2017-07-17 17:18:38 -03:00
XSLT.pm Bug 17835: Replace GetItemTypes with Koha::ItemTypes 2017-04-14 10:43:51 -04:00