Commit 96329d63 authored by Monty's avatar Monty

Fixed that CHECK TABLE on an S3 table doesn't try to write to files

The symtom of the bug was that check table on an S3 table when using
--s3_slave-ignore-updates=1 could print "9 when updating keyfile"
parent ea40c75c
...@@ -640,6 +640,7 @@ int ha_s3::open(const char *name, int mode, uint open_flags) ...@@ -640,6 +640,7 @@ int ha_s3::open(const char *name, int mode, uint open_flags)
file->dfile.big_block_size= file->s->kfile.big_block_size= file->dfile.big_block_size= file->s->kfile.big_block_size=
file->s->bitmap.file.big_block_size= file->s->base.s3_block_size; file->s->bitmap.file.big_block_size= file->s->base.s3_block_size;
file->s->kfile.head_blocks= file->s->base.keystart / file->s->block_size; file->s->kfile.head_blocks= file->s->base.keystart / file->s->block_size;
file->s->no_status_updates= in_alter_table == S3_NO_ALTER;
} }
} }
open_args= 0; open_args= 0;
......
...@@ -6326,6 +6326,9 @@ int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update) ...@@ -6326,6 +6326,9 @@ int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update)
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_update_state_info"); DBUG_ENTER("maria_update_state_info");
if (info->s->no_status_updates)
DBUG_RETURN(0); /* S3 readonly table */
if (update & UPDATE_OPEN_COUNT) if (update & UPDATE_OPEN_COUNT)
{ {
share->state.open_count=0; share->state.open_count=0;
......
...@@ -1461,6 +1461,7 @@ int _ma_update_state_lsns_sub(MARIA_SHARE *share, LSN lsn, TrID create_trid, ...@@ -1461,6 +1461,7 @@ int _ma_update_state_lsns_sub(MARIA_SHARE *share, LSN lsn, TrID create_trid,
File file= share->kfile.file; File file= share->kfile.file;
DBUG_ENTER("_ma_update_state_lsns_sub"); DBUG_ENTER("_ma_update_state_lsns_sub");
DBUG_ASSERT(file >= 0); DBUG_ASSERT(file >= 0);
CRASH_IF_S3_TABLE(share);
if (lsn == LSN_IMPOSSIBLE) if (lsn == LSN_IMPOSSIBLE)
{ {
......
...@@ -303,6 +303,8 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation) ...@@ -303,6 +303,8 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation)
/* transactional tables flush their state at Checkpoint */ /* transactional tables flush their state at Checkpoint */
if (operation) if (operation)
{ /* Two threads can't be here */ { /* Two threads can't be here */
CRASH_IF_S3_TABLE(info->s); /* S3 readonly doesn't come here */
olderror= my_errno; /* Remember last error */ olderror= my_errno; /* Remember last error */
#ifdef MARIA_EXTERNAL_LOCKING #ifdef MARIA_EXTERNAL_LOCKING
...@@ -446,6 +448,7 @@ int _ma_mark_file_changed_now(register MARIA_SHARE *share) ...@@ -446,6 +448,7 @@ int _ma_mark_file_changed_now(register MARIA_SHARE *share)
*/ */
if (!share->temporary) if (!share->temporary)
{ {
CRASH_IF_S3_TABLE(share);
mi_int2store(buff,share->state.open_count); mi_int2store(buff,share->state.open_count);
buff[2]=1; /* Mark that it's changed */ buff[2]=1; /* Mark that it's changed */
if (my_pwrite(share->kfile.file, buff, sizeof(buff), if (my_pwrite(share->kfile.file, buff, sizeof(buff),
...@@ -458,6 +461,7 @@ int _ma_mark_file_changed_now(register MARIA_SHARE *share) ...@@ -458,6 +461,7 @@ int _ma_mark_file_changed_now(register MARIA_SHARE *share)
if (share->base.born_transactional && if (share->base.born_transactional &&
!(share->state.org_changed & STATE_NOT_MOVABLE)) !(share->state.org_changed & STATE_NOT_MOVABLE))
{ {
CRASH_IF_S3_TABLE(share);
/* Lock table to current installation */ /* Lock table to current installation */
if (_ma_set_uuid(share, 0) || if (_ma_set_uuid(share, 0) ||
(share->state.create_rename_lsn == LSN_NEEDS_NEW_STATE_LSNS && (share->state.create_rename_lsn == LSN_NEEDS_NEW_STATE_LSNS &&
...@@ -518,6 +522,7 @@ int _ma_decrement_open_count(MARIA_HA *info, my_bool lock_tables) ...@@ -518,6 +522,7 @@ int _ma_decrement_open_count(MARIA_HA *info, my_bool lock_tables)
/* Its not fatal even if we couldn't get the lock ! */ /* Its not fatal even if we couldn't get the lock ! */
if (share->state.open_count > 0) if (share->state.open_count > 0)
{ {
CRASH_IF_S3_TABLE(share);
share->state.open_count--; share->state.open_count--;
share->changed= 1; /* We have to update state */ share->changed= 1; /* We have to update state */
/* /*
...@@ -548,9 +553,15 @@ void _ma_mark_file_crashed(MARIA_SHARE *share) ...@@ -548,9 +553,15 @@ void _ma_mark_file_crashed(MARIA_SHARE *share)
{ {
uchar buff[2]; uchar buff[2];
DBUG_ENTER("_ma_mark_file_crashed"); DBUG_ENTER("_ma_mark_file_crashed");
CRASH_IF_S3_TABLE(share);
share->state.changed|= STATE_CRASHED; share->state.changed|= STATE_CRASHED;
if (share->no_status_updates)
DBUG_VOID_RETURN; /* Safety */
mi_int2store(buff, share->state.changed); mi_int2store(buff, share->state.changed);
/* /*
We can ignore the errors, as if the mark failed, there isn't anything We can ignore the errors, as if the mark failed, there isn't anything
else we can do; The user should already have got an error that the else we can do; The user should already have got an error that the
...@@ -606,6 +617,7 @@ my_bool _ma_set_uuid(MARIA_SHARE *share, my_bool reset_uuid) ...@@ -606,6 +617,7 @@ my_bool _ma_set_uuid(MARIA_SHARE *share, my_bool reset_uuid)
bzero(buff, sizeof(buff)); bzero(buff, sizeof(buff));
uuid= buff; uuid= buff;
} }
CRASH_IF_S3_TABLE(share);
return (my_bool) my_pwrite(share->kfile.file, uuid, MY_UUID_SIZE, return (my_bool) my_pwrite(share->kfile.file, uuid, MY_UUID_SIZE,
mi_uint2korr(share->state.header.base_pos), mi_uint2korr(share->state.header.base_pos),
MYF(MY_NABP)); MYF(MY_NABP));
......
...@@ -787,6 +787,7 @@ typedef struct st_maria_share ...@@ -787,6 +787,7 @@ typedef struct st_maria_share
my_bool changed, /* If changed since lock */ my_bool changed, /* If changed since lock */
global_changed, /* If changed since open */ global_changed, /* If changed since open */
not_flushed; not_flushed;
my_bool no_status_updates; /* Set to 1 if S3 readonly table */
my_bool internal_table; /* Internal tmp table */ my_bool internal_table; /* Internal tmp table */
my_bool lock_key_trees; /* If we have to lock trees on read */ my_bool lock_key_trees; /* If we have to lock trees on read */
my_bool non_transactional_concurrent_insert; my_bool non_transactional_concurrent_insert;
...@@ -1768,3 +1769,5 @@ static inline void decrement_share_in_trans(MARIA_SHARE *share) ...@@ -1768,3 +1769,5 @@ static inline void decrement_share_in_trans(MARIA_SHARE *share)
} }
C_MODE_END C_MODE_END
#endif #endif
#define CRASH_IF_S3_TABLE(share) DBUG_ASSERT(!share->no_status_updates)
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