From a70b8961f4b8b4862677b60b925282ca1d3063d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 15 Feb 2016 18:38:15 +0200 Subject: [PATCH] MDEV-9424: Server crashes when slave works with partitioned tables copied from Windows to Linux Add check to avoid NULL-pointer access and added warning if share->ib_table is not what expected. --- storage/xtradb/handler/ha_innodb.cc | 72 +++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 594d73b2d86..2f0594dbb6d 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -7563,7 +7563,13 @@ ha_innobase::write_row( ha_statistic_increment(&SSV::ha_write_count); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -7799,7 +7805,13 @@ report_error: func_exit: innobase_active_small(); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -8131,7 +8143,13 @@ ha_innobase::update_row( ha_statistic_increment(&SSV::ha_update_count); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -8228,7 +8246,13 @@ func_exit: innobase_active_small(); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -11097,7 +11121,13 @@ ha_innobase::truncate() update_thd(ha_thd()); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -11112,7 +11142,13 @@ ha_innobase::truncate() err = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); } @@ -12407,7 +12443,13 @@ ha_innobase::analyze( { int ret; - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { return(HA_ADMIN_CORRUPT); } @@ -12417,7 +12459,13 @@ ha_innobase::analyze( HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE, true /* this is ANALYZE */); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { return(HA_ADMIN_CORRUPT); } @@ -13585,7 +13633,13 @@ ha_innobase::transactional_table_lock( update_thd(thd); - if (UNIV_UNLIKELY(share->ib_table->is_corrupt)) { + if (share->ib_table != prebuilt->table) { + fprintf(stderr, + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); + } + + if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); }