Koha/t
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
..
Acquisition Bug 18756 - add Unit Test 2017-07-06 14:29:02 -03:00
Biblio Bug 18951: Some t/Biblio tests are database dependent (git mv) 2017-07-24 13:37:18 -03:00
Budgets Bug 18942: (QA followup) Add new tests descriptions 2017-07-17 15:52:01 -03:00
Circulation Bug 17557: Koha::Patrons - Move GetAge to ->set_age (and remove SetAge) 2016-12-16 11:57:38 +00:00
db_dependent Bug 18966: Do not deal with duplicate issue_id on checkin 2017-07-26 13:50:57 -03:00
edi_testfiles Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
etc Bug 18286: [Follow-up] Add t/etc/schema.pl 2017-06-05 17:52:35 -03:00
External Bug 16636 [QA Followup] - Move tests to t/External 2016-06-10 18:02:14 +00:00
Koha Bug 17302: [Follow-up] Make Normalize.pm undef-resistent 2016-09-25 14:04:54 +00:00
lib Bug 18361: Koha::Objects->find should accept composite primary keys 2017-06-16 11:52:18 -03:00
Members Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 2017-06-05 17:52:47 -03:00
Number Bug 16768: Add tests for Swiss number format 2016-06-24 14:00:03 +00:00
Search
Serials Bug 16289: Refactore code and add tests 2016-06-10 18:09:48 +00:00
SIP Bug 15006: Centralize timeout logic and allow zero client timeout 2016-07-15 14:11:05 +00:00
00-checkdatabase-version.t
00-deprecated.t
00-load.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 2017-06-05 17:52:47 -03:00
00-merge-conflict-markers.t
00-testcritic.t
00-valid-xml.t Bug 16608 - Add xsd extension to t/00-valid-xml.t 2016-06-10 17:40:55 +00:00
Auth_with_shibboleth.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
AuthoritiesMarc_MARC21.t
AuthoritiesMarc_UNIMARC.t
AuthUtils.t
Barcodes_annual.t
Barcodes_EAN13.t
Barcodes_hbyymmincr.t
Barcodes_incremental.t
Biblio.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
Biblio2.t Bug 16556 - KohaToMarcMapped columns sharing same field with biblio(item)number are removed. 2016-09-15 13:42:35 +00:00
Bookseller.t
Boolean.t
Budgets.t
Cache.t Bug 16769: Uniformise calls to Koha::Cache->set_in_cache 2016-10-10 17:03:54 +00:00
Calendar.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
Charset.t Bug 18152: Add tests 2017-05-08 08:36:57 -04:00
Circulation_barcodedecode.t
ClassSortRoutine.t
ClassSortRoutine_Dewey.t
ClassSortRoutine_Generic.t
ClassSortRoutine_LCC.t
ClassSource.t
Context.t
Contract.t
Creators.t Bug 16622: some tests triggered by prove t fail for unset KOHA_CONF 2016-08-05 06:09:58 +00:00
DateUtils.t Bug 17502: Throw some exceptions in output_pref 2017-04-21 07:36:25 -04:00
Debug.t
dummy.t
Edifact.t Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
EdiInvoice.t Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
Ediorder.t Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
Ediordrsp.t Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
Form_MessagingPreferences.t
Heading.t
HtmlTags.t Bug 18665: Add test for HtmlTags.pm 2017-06-21 11:22:19 -03:00
Images.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
ImportBatch.t Bug 10407: Add two subtests to t/ImportBatch.t 2016-09-02 16:00:13 +00:00
Installer_PerlDependencies.t
Installer_PerlModules.t Bug 17990: Refactor Perl module versions check 2017-02-17 12:13:44 +00:00
Installer_pm.t Bug 17990: Refactor Perl module versions check 2017-02-17 12:13:44 +00:00
ItemCirculationAlertPreference.t
Koha.t Bug 18287 - Fix t/Koha.t having a Test::DBIx::Class cache issue 2017-06-05 17:52:48 -03:00
Koha_Email.t
Koha_ExternalContent_OverDrive.t Bug 18243: 16034 follow-up: better handling of absence of WebService::ILS::OverDrive::Patron at testing 2017-03-20 15:28:35 +00:00
Koha_MetadataRecord.t
Koha_Template_Plugin_Cache.t
Koha_Template_Plugin_Koha.t Bug 18222 - Fix tests broken by Buug 18026 2017-03-20 15:33:45 +00:00
Koha_Util_FrameworkPlugin.t
Koha_Util_MARC.t
Labels.t
Labels_split_ccn.t
Labels_split_ddcn.t
Labels_split_lccn.t
Languages.t Bug 16675: fix breakage of t/Languages.t 2016-06-10 17:03:10 +00:00
Letters.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
Log.t
Logger.t
Matcher.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
Members_Attributes.t Bug 12267: Remove borrower_attributes.password 2016-04-22 23:08:32 +00:00
Members_AttributeTypes.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
Members_Messaging.t
NorwegianPatronDB.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00
OpenLibrarySearch.t Bug 16649: Make OpenLibrarySearch test pass even if launches offline 2016-06-10 17:05:03 +00:00
Output.t
Output_JSONStream.t
Patron.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 2017-06-05 17:52:47 -03:00
Patroncards.t
Patroncards_Batch.t
Patroncards_Layout.t
Patroncards_Lib.t
Patroncards_Patroncard.t
Patroncards_Profile.t
Patroncards_Template.t
perlcriticrc
Prices.t Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue 2017-06-05 17:52:49 -03:00
Print.t
QueryParser.t
RecordProcessor.t
Ris.t Bug 16668: Fix t/Ris.t tests 2016-06-10 16:59:20 +00:00
Scheduler.t
Scrubber.t
Search.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 2017-06-05 17:52:47 -03:00
Search_PazPar2.t
SimpleMARC.t
smolder_smoke_signal
SMS.t
SocialData.t Bug 18288 - Fix t/SocialData.t having a Test::DBIx::Class cache issue 2017-06-05 17:52:48 -03:00
Stats.t
SuggestionEngine.t
SuggestionEngine_AuthorityFile.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 2017-06-05 17:52:47 -03:00
TmplToken.t
Token.t Bug 18124: [Follow-up] Handle default parameters in a sub 2017-03-30 09:07:08 +00:00
XSLT.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication 2017-06-05 17:52:48 -03:00