[MDEV-8751] Result of DISCARD TABLESPACE depends on innodb_stats_persistent Created: 2015-09-04  Updated: 2015-09-07  Resolved: 2015-09-07

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Storage Engine - XtraDB
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Jan Lindström (Inactive)
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

Note: Observed on bb-10.1-jan-encryption. The test case below is pretty much the same as in MDEV-8750, just a little bit simplified. I don't know whether the issue is anyhow related to encryption, maybe it can be observed without it, I'm just using the test case that I already have.

Test flow

- start server with the encryption plugin;
- create and populate an encrypted InnoDB table;
- restart server without the encryption plugin;
- attempt to select from the table (error);
- attempt to discard tablespace of the table
  => problem

The problem is that the result of DISCARD TABLESPACE is different if the server was started with innodb_stats_persistent enabled (default) or disabled. If it's disnabled, the ALTER succeeds with warnings. If it's enabled, ALTER fails.

Dependency on a seemingly unrelated option is disturbing, so at least it's worth checking whether it's intentional.

Test case

--source include/have_innodb.inc
 
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
 
--write_file $MYSQLTEST_VARDIR/keys1.txt
1;770A8A65DA156D24EE2A093277530142
EOF
 
--exec echo "restart:--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
 
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
 
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
 
--write_file $MYSQLTEST_VARDIR/keys2.txt
1;770A8A65DA156D24EE2A093277530143
EOF
 
--exec echo "restart:--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
 
--error ER_NO_SUCH_TABLE_IN_ENGINE
select * from t1;
--error ER_NO_SUCH_TABLE_IN_ENGINE
alter table t1 discard tablespace;

Result 1

# Run with --mysqld=--innodb-stats-persistent=1
 
select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
alter table t1 discard tablespace;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
bug.t6 'innodb_plugin'                   [ fail ]  Found warnings/errors in server log file!
        Test ended at 2015-09-04 14:43:23
line
2015-09-04 14:43:23 140172686374656 [ERROR] InnoDB: Block in space_id 4 in file test/t1 encrypted.
2015-09-04 14:43:23 140172686374656 [ERROR] InnoDB: However key management plugin or used key_id 1 is not found or used encryption algorithm or method does not match.
2015-09-04 14:43:23 140172686374656 [ERROR] InnoDB: Marking tablespace as missing. You may drop this table or install correct key management plugin and key file.
2015-09-04 14:43:23 140172686374656 [ERROR] InnoDB: Block in space_id 4 in file test/t1 encrypted.
2015-09-04 14:43:23 140172686374656 [ERROR] InnoDB: However key management plugin or used key_id 1 is not found or used encryption algorithm or method does not match.
2015-09-04 14:43:23 140172686374656 [ERROR] InnoDB: Marking tablespace as missing. You may drop this table or install correct key management plugin and key file.

Result 2

# Run with --mysqld=--innodb-stats-persistent=0
 
select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
alter table t1 discard tablespace;
bug.t6 'innodb_plugin'                   [ fail ]
        Test ended at 2015-09-04 14:44:34
 
CURRENT_TEST: bug.t6
mysqltest: At line 33: query 'alter table t1 discard tablespace' succeeded - should have failed with errno 1932...
 
Warnings from just before the error:
Warning 1812 Tablespace is missing for table 'test/t1'



 Comments   
Comment by Jan Lindström (Inactive) [ 2015-09-07 ]

Option is not unrelated. To gather persistent statistics from a table, you need to read at least few pages from that table to get e.g. size. If table is encrypted, you can't read pages and estimate the size. After you have read pages from the table, table is not anymore usable (because we mark it encrypted). If you do not read any pages, you should still be able to discard tablespace to get rid of table (drop might actually also work on some cases).

Comment by Elena Stepanova [ 2015-09-07 ]

Fair enough. It would be nice to document subtleties like this (not urgently, but some time), it's really not obvious and can cause confusion. Of course, users won't read this documentation until they encounter the oddity, but at least it will be easier to find explanation.

Generated at Thu Feb 08 07:29:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.