From 06ec56f579e6de647fd38854da31b6324100faf9 Mon Sep 17 00:00:00 2001 From: Sachin Agarwal Date: Mon, 26 Nov 2018 16:17:40 +0530 Subject: [PATCH 1/3] Bug #27850600 INNODB ASYNC IO ERROR HANDLING IN IO_EVENT Problem: io_getevents() - read asynchronous I/O events from the completion queue. For each IO event, the res field in io_event tells whether IO event is succeeded or not. To see if the IO actually succeeded we always need to check event.res (negative=error, positive=bytesread/written). LinuxAIOHandler::collect() doesn't check event.res value for each event. which leads to incorrect value in n_bytes for IO context (or IO Slot). Fix: Added a check for event.res negative value. RB: 20871 Reviewed by : annamalai.gurusami@oracle.com --- storage/innobase/os/os0file.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 10a8f44b062..98a328c7f47 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1962,10 +1962,24 @@ LinuxAIOHandler::collect() will be done in the calling function. */ m_array->acquire(); - slot->ret = events[i].res2; + /* events[i].res2 should always be ZERO */ + ut_ad(events[i].res2 == 0); slot->io_already_done = true; - slot->n_bytes = events[i].res; + /*Even though events[i].res is an unsigned number + in libaio, it is used to return a negative value + (negated errno value) to indicate error and a positive + value to indicate number of bytes read or written. */ + + if (events[i].res > slot->len) { + /* failure */ + slot->n_bytes = 0; + slot->ret = events[i].res; + } else { + /* success */ + slot->n_bytes = events[i].res; + slot->ret = 0; + } m_array->release(); } From c795a9f3fea60d303645c6729834cdd389aaed0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 26 Apr 2019 10:13:29 +0300 Subject: [PATCH 2/3] MDEV-12004: Add the Bug#28825718 test case Adapt the test case from mysql/mysql-server@2bbbcddd903626c84c610dd2ed82cc22ee4d6cde (MySQL 5.7.26). --- .../suite/gcol/r/innodb_virtual_debug.result | 30 ++++++++++++++++ .../suite/gcol/t/innodb_virtual_debug.test | 34 ++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/gcol/r/innodb_virtual_debug.result b/mysql-test/suite/gcol/r/innodb_virtual_debug.result index 50b714566d9..806cf1a98c8 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_debug.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_debug.result @@ -94,3 +94,33 @@ NULL 29 DROP TABLE t; SET DEBUG_SYNC = 'RESET'; +# +# Bug#28825718 - ASSERTION FAILURE: TRX0REC.CC:NNN:N_IDX > 0 WHILE DOING REPLACE/INSERT +# +CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT GENERATED ALWAYS AS(b+1) VIRTUAL) ENGINE=InnoDB; +INSERT INTO t1(a, b) VALUES(1, 1); +connect con1,localhost,root,,; +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL s1 WAIT_FOR s2'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ADD UNIQUE INDEX(c, b); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR s1'; +SET DEBUG_SYNC = 'row_ins_sec_index_enter SIGNAL s2 WAIT_FOR s3'; +INSERT INTO t1(a, b) VALUES(2, 2); +connection con1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL s3'; +disconnect con1; +connection default; +SET DEBUG_SYNC = 'RESET'; +ALTER TABLE t1 ADD KEY(b); +INSERT INTO t1(a, b) VALUES(3, 3); +SELECT * FROM t1; +a b c +1 1 2 +2 2 3 +3 3 4 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_debug.test b/mysql-test/suite/gcol/t/innodb_virtual_debug.test index ccdd16c9ebe..40446b991cd 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_debug.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_debug.test @@ -60,7 +60,6 @@ SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR --send ALTER TABLE t FORCE connection con1; - SET DEBUG_SYNC = 'now WAIT_FOR start_create'; start transaction; update t set a=1 where a = 0; @@ -280,4 +279,37 @@ disconnect con1; } SET DEBUG_SYNC = 'RESET'; + +--echo # +--echo # Bug#28825718 - ASSERTION FAILURE: TRX0REC.CC:NNN:N_IDX > 0 WHILE DOING REPLACE/INSERT +--echo # + +CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT GENERATED ALWAYS AS(b+1) VIRTUAL) ENGINE=InnoDB; + +INSERT INTO t1(a, b) VALUES(1, 1); + +connect (con1,localhost,root,,); +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL s1 WAIT_FOR s2'; +SET lock_wait_timeout = 1; +--send ALTER TABLE t1 ADD UNIQUE INDEX(c, b) + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR s1'; +SET DEBUG_SYNC = 'row_ins_sec_index_enter SIGNAL s2 WAIT_FOR s3'; +--send INSERT INTO t1(a, b) VALUES(2, 2) + +connection con1; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET DEBUG_SYNC = 'now SIGNAL s3'; +disconnect con1; +connection default; +reap; +SET DEBUG_SYNC = 'RESET'; +ALTER TABLE t1 ADD KEY(b); +INSERT INTO t1(a, b) VALUES(3, 3); +SELECT * FROM t1; +CHECK TABLE t1; +DROP TABLE t1; + --source include/wait_until_count_sessions.inc From f3a9f12bc327d9568488999a20120eabcd1e6d68 Mon Sep 17 00:00:00 2001 From: Aditya A Date: Fri, 25 Jan 2019 19:51:57 +0530 Subject: [PATCH 3/3] Bug #29021730 CRASHING INNOBASE_COL_CHECK_FK WITH FOREIGN KEYS PROBLEM ------- Function innodb_base_col_setup_for_stored() was skipping to store the base column information for a generated column if the base column was a "STORED" generated column. This later causes a crash in function innoabse_col_check_fk() where it says that a generated columns depends upon two base columns ,but there is information on only one of them. There was a explicit check barring the stored columns being stored, which is wrong because the documentation says that a generated stored column can be a part of a generated column. FIX ---- Store the information of base column if it is a stored generated column. #RB21247 Reviewed by: Debarun Banerjee --- storage/innobase/handler/ha_innodb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d9ee942324a..953a4d89037 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -10977,7 +10977,7 @@ innodb_base_col_setup_for_stored( for (uint i= 0; i < field->table->s->fields; ++i) { const Field* base_field = field->table->field[i]; - if (!base_field->vcol_info + if (base_field->stored_in_db() && bitmap_is_set(&field->table->tmp_set, i)) { ulint z; for (z = 0; z < table->n_cols; z++) {