Commit 25fa2a68 authored by Monty's avatar Monty

MDEV-25507 CHECK on encrypted Aria table complains about "Wrong LSN"

This happens during repair when a temporary table is opened
with HA_OPEN_COPY, which resets 'share->born_transactional', which
the encryption code did not like.

Fixed by resetting just share->now_transactional.
parent 42cdc37f
set global aria_encrypt_tables = 1; SET @aria_encrypt= @@aria_encrypt_tables;
SET global aria_encrypt_tables=1;
create table t1 (i int, key(i)) engine=aria; create table t1 (i int, key(i)) engine=aria;
insert into t1 values (1); insert into t1 values (1);
drop table t1; drop table t1;
...@@ -10,4 +11,17 @@ check table t1; ...@@ -10,4 +11,17 @@ check table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
drop table t1; drop table t1;
set global aria_encrypt_tables = 0; #
# MDEV CHECK on encrypted Aria table complains about "Wrong LSN"
#
CREATE TABLE t1 (f DATE PRIMARY KEY) ENGINE=Aria;
INSERT INTO t1 (f) VALUES ('1995-01-01'),('2000-01-01');
DELETE FROM t1 WHERE f = '2000-01-01';
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
set global aria_encrypt_tables=@aria_encrypt;
--source include/have_file_key_management_plugin.inc --source include/have_file_key_management_plugin.inc
--source include/have_sequence.inc --source include/have_sequence.inc
SET @aria_encrypt= @@aria_encrypt_tables;
SET global aria_encrypt_tables=1;
# #
# MDEV-8022 Assertion `rc == 0' failed in ma_encrypt on dropping an encrypted Aria table # MDEV-8022 Assertion `rc == 0' failed in ma_encrypt on dropping an encrypted Aria table
# #
set global aria_encrypt_tables = 1;
create table t1 (i int, key(i)) engine=aria; create table t1 (i int, key(i)) engine=aria;
insert into t1 values (1); insert into t1 values (1);
drop table t1; drop table t1;
...@@ -24,7 +26,18 @@ alter table t1 enable keys; ...@@ -24,7 +26,18 @@ alter table t1 enable keys;
check table t1; check table t1;
drop table t1; drop table t1;
--echo #
--echo # MDEV CHECK on encrypted Aria table complains about "Wrong LSN"
--echo #
CREATE TABLE t1 (f DATE PRIMARY KEY) ENGINE=Aria;
INSERT INTO t1 (f) VALUES ('1995-01-01'),('2000-01-01');
DELETE FROM t1 WHERE f = '2000-01-01';
OPTIMIZE TABLE t1;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
# #
# Cleanup # Cleanup
# #
set global aria_encrypt_tables = 0; set global aria_encrypt_tables=@aria_encrypt;
...@@ -179,7 +179,8 @@ int maria_close(register MARIA_HA *info) ...@@ -179,7 +179,8 @@ int maria_close(register MARIA_HA *info)
mysql_rwlock_destroy(&share->keyinfo[i].root_lock); mysql_rwlock_destroy(&share->keyinfo[i].root_lock);
} }
} }
DBUG_ASSERT(share->now_transactional == share->base.born_transactional); DBUG_ASSERT(share->now_transactional == share->base.born_transactional ||
share->internal_table);
/* /*
We assign -1 because checkpoint does not need to flush (in case we We assign -1 because checkpoint does not need to flush (in case we
have concurrent checkpoint if no then we do not need it here also) have concurrent checkpoint if no then we do not need it here also)
......
...@@ -187,9 +187,9 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, ...@@ -187,9 +187,9 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
maria_delay_key_write) maria_delay_key_write)
share->delay_key_write=1; share->delay_key_write=1;
if (!share->base.born_transactional) /* For transactional ones ... */ if (!share->now_transactional) /* If not transctional table */
{ {
/* ... force crash if no trn given */ /* Pagecache requires access to info->trn->rec_lsn */
_ma_set_tmp_trn_for_table(&info, &dummy_transaction_object); _ma_set_tmp_trn_for_table(&info, &dummy_transaction_object);
info.state= &share->state.state; /* Change global values by default */ info.state= &share->state.state; /* Change global values by default */
} }
...@@ -282,7 +282,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -282,7 +282,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
ulong *nulls_per_key_part; ulong *nulls_per_key_part;
my_off_t key_root[HA_MAX_POSSIBLE_KEY]; my_off_t key_root[HA_MAX_POSSIBLE_KEY];
ulonglong max_key_file_length, max_data_file_length; ulonglong max_key_file_length, max_data_file_length;
my_bool versioning= 1; my_bool versioning= 1, born_transactional;
File data_file= -1, kfile= -1; File data_file= -1, kfile= -1;
struct ms3_st *s3_client= 0; struct ms3_st *s3_client= 0;
S3_INFO *share_s3= 0; S3_INFO *share_s3= 0;
...@@ -526,6 +526,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -526,6 +526,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
file_version= (share->state.header.not_used == 0); file_version= (share->state.header.not_used == 0);
if (file_version == 0) if (file_version == 0)
share->base.language= share->state.header.not_used; share->base.language= share->state.header.not_used;
born_transactional= share->base.born_transactional;
share->state.state_length=base_pos; share->state.state_length=base_pos;
/* For newly opened tables we reset the error-has-been-printed flag */ /* For newly opened tables we reset the error-has-been-printed flag */
...@@ -560,7 +561,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -560,7 +561,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
We can ignore testing uuid if STATE_NOT_MOVABLE is not set, as in this We can ignore testing uuid if STATE_NOT_MOVABLE is not set, as in this
case the uuid will be set in _ma_mark_file_changed(). case the uuid will be set in _ma_mark_file_changed().
*/ */
if (share->base.born_transactional && if (born_transactional &&
((share->state.create_trid > trnman_get_max_trid() && ((share->state.create_trid > trnman_get_max_trid() &&
!maria_in_recovery) || !maria_in_recovery) ||
((share->state.changed & STATE_NOT_MOVABLE) && ((share->state.changed & STATE_NOT_MOVABLE) &&
...@@ -601,7 +602,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -601,7 +602,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
} }
/* Ensure we have space in the key buffer for transaction id's */ /* Ensure we have space in the key buffer for transaction id's */
if (share->base.born_transactional) if (born_transactional)
share->base.max_key_length= ALIGN_SIZE(share->base.max_key_length + share->base.max_key_length= ALIGN_SIZE(share->base.max_key_length +
MARIA_MAX_PACK_TRANSID_SIZE); MARIA_MAX_PACK_TRANSID_SIZE);
...@@ -700,7 +701,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -700,7 +701,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
share->block_size= share->base.block_size; /* Convenience */ share->block_size= share->base.block_size; /* Convenience */
share->max_index_block_size= share->block_size - KEYPAGE_CHECKSUM_SIZE; share->max_index_block_size= share->block_size - KEYPAGE_CHECKSUM_SIZE;
share->keypage_header= ((share->base.born_transactional ? share->keypage_header= ((born_transactional ?
LSN_STORE_SIZE + TRANSID_SIZE : LSN_STORE_SIZE + TRANSID_SIZE :
0) + KEYPAGE_KEYID_SIZE + KEYPAGE_FLAG_SIZE + 0) + KEYPAGE_KEYID_SIZE + KEYPAGE_FLAG_SIZE +
KEYPAGE_USED_SIZE); KEYPAGE_USED_SIZE);
...@@ -723,7 +724,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -723,7 +724,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
/* Calculate length to store a key + nod flag and transaction info */ /* Calculate length to store a key + nod flag and transaction info */
keyinfo->max_store_length= (keyinfo->maxlength + keyinfo->max_store_length= (keyinfo->maxlength +
share->base.key_reflength); share->base.key_reflength);
if (share->base.born_transactional) if (born_transactional)
keyinfo->max_store_length+= MARIA_INDEX_OVERHEAD_SIZE; keyinfo->max_store_length+= MARIA_INDEX_OVERHEAD_SIZE;
/* See ma_delete.cc::underflow() */ /* See ma_delete.cc::underflow() */
...@@ -862,9 +863,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -862,9 +863,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
file for REPAIR. Don't do logging. This base information will not go file for REPAIR. Don't do logging. This base information will not go
to disk. to disk.
*/ */
share->base.born_transactional= FALSE; born_transactional= FALSE;
} }
if (share->base.born_transactional) if (born_transactional)
{ {
share->page_type= PAGECACHE_LSN_PAGE; share->page_type= PAGECACHE_LSN_PAGE;
if (share->state.create_rename_lsn == LSN_NEEDS_NEW_STATE_LSNS) if (share->state.create_rename_lsn == LSN_NEEDS_NEW_STATE_LSNS)
...@@ -915,7 +916,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -915,7 +916,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
} }
else else
share->page_type= PAGECACHE_PLAIN_PAGE; share->page_type= PAGECACHE_PLAIN_PAGE;
share->now_transactional= share->base.born_transactional; share->now_transactional= born_transactional;
/* Use pack_reclength as we don't want to modify base.pack_recklength */ /* Use pack_reclength as we don't want to modify base.pack_recklength */
if (share->state.header.org_data_file_type == DYNAMIC_RECORD) if (share->state.header.org_data_file_type == DYNAMIC_RECORD)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment