Relax assertions on shutdown after aborted startup.

A proper InnoDB shutdown after aborted startup was introduced
in commit 81b7fe9d38.

Also related to this is MDEV-11985, making read-only shutdown more robust.

If startup was aborted, there may exist recovered transactions that were
not rolled back. Relax the assertions accordingly.
This commit is contained in:
Marko Mäkelä 2017-02-09 10:04:00 +02:00
commit 66c6188a4b
6 changed files with 31 additions and 9 deletions

View file

@ -11,9 +11,16 @@ DELETE FROM t1;
SELECT * FROM t1; SELECT * FROM t1;
a a
42 42
INSERT INTO t1 VALUES (123); INSERT INTO t1 VALUES (0),(123);
BEGIN; BEGIN;
DELETE FROM t1; DELETE FROM t1 WHERE a>0;
# Persist the state of the above incomplete transaction by
# causing a redo log write for another transaction.
connect con1, localhost, root;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a=0;
disconnect con1;
connection default;
# Kill the server # Kill the server
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB' ERROR 42000: Unknown storage engine 'InnoDB'

View file

@ -49,7 +49,7 @@ let $restart_parameters = --innodb-log-files-in-group=3 --innodb-log-file-size=5
SELECT * FROM t1; SELECT * FROM t1;
INSERT INTO t1 VALUES (123); INSERT INTO t1 VALUES (0),(123);
let MYSQLD_DATADIR= `select @@datadir`; let MYSQLD_DATADIR= `select @@datadir`;
let SEARCH_ABORT = NOT FOUND; let SEARCH_ABORT = NOT FOUND;
@ -57,7 +57,15 @@ let SEARCH_RANGE= -50000;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
BEGIN; BEGIN;
DELETE FROM t1; DELETE FROM t1 WHERE a>0;
--echo # Persist the state of the above incomplete transaction by
--echo # causing a redo log write for another transaction.
--connect(con1, localhost, root)
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a=0;
--disconnect con1
--connection default
--source include/kill_mysqld.inc --source include/kill_mysqld.inc

View file

@ -7609,7 +7609,8 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
if (!(item= new (mem_root) if (!(item= new (mem_root)
Item_blob(thd, fields_info->field_name, Item_blob(thd, fields_info->field_name,
fields_info->field_length))) std::min(unsigned (strlen(fields_info->field_name)),
fields_info->field_length))))
{ {
DBUG_RETURN(0); DBUG_RETURN(0);
} }

View file

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -1097,6 +1098,7 @@ trx_sys_close(void)
/* Only prepared transactions may be left in the system. Free them. */ /* Only prepared transactions may be left in the system. Free them. */
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == trx_sys->n_prepared_trx ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == trx_sys->n_prepared_trx
|| !srv_was_started
|| srv_read_only_mode || srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);

View file

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2016, MariaDB Corporation. Copyright (c) 2015, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -635,7 +635,8 @@ trx_free_prepared(
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED) ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)
|| (trx_state_eq(trx, TRX_STATE_ACTIVE) || (trx_state_eq(trx, TRX_STATE_ACTIVE)
&& trx->is_recovered && trx->is_recovered
&& (srv_read_only_mode && (!srv_was_started
|| srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO))); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO)));
ut_a(trx->magic_n == TRX_MAGIC_N); ut_a(trx->magic_n == TRX_MAGIC_N);

View file

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -2021,7 +2022,8 @@ trx_undo_free_prepared(
case TRX_UNDO_ACTIVE: case TRX_UNDO_ACTIVE:
/* lock_trx_release_locks() assigns /* lock_trx_release_locks() assigns
trx->is_recovered=false */ trx->is_recovered=false */
ut_a(srv_read_only_mode ut_a(!srv_was_started
|| srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
break; break;
default: default:
@ -2042,7 +2044,8 @@ trx_undo_free_prepared(
case TRX_UNDO_ACTIVE: case TRX_UNDO_ACTIVE:
/* lock_trx_release_locks() assigns /* lock_trx_release_locks() assigns
trx->is_recovered=false */ trx->is_recovered=false */
ut_a(srv_read_only_mode ut_a(!srv_was_started
|| srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
break; break;
default: default: