Skip to content
Permalink
Browse files
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"
  • Loading branch information
montywi committed May 29, 2022
1 parent ea40c75 commit 96329d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
@@ -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->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->no_status_updates= in_alter_table == S3_NO_ALTER;
}
}
open_args= 0;
@@ -6326,6 +6326,9 @@ int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update)
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_update_state_info");

if (info->s->no_status_updates)
DBUG_RETURN(0); /* S3 readonly table */

if (update & UPDATE_OPEN_COUNT)
{
share->state.open_count=0;
@@ -1461,6 +1461,7 @@ int _ma_update_state_lsns_sub(MARIA_SHARE *share, LSN lsn, TrID create_trid,
File file= share->kfile.file;
DBUG_ENTER("_ma_update_state_lsns_sub");
DBUG_ASSERT(file >= 0);
CRASH_IF_S3_TABLE(share);

if (lsn == LSN_IMPOSSIBLE)
{
@@ -303,6 +303,8 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation)
/* transactional tables flush their state at Checkpoint */
if (operation)
{ /* Two threads can't be here */
CRASH_IF_S3_TABLE(info->s); /* S3 readonly doesn't come here */

olderror= my_errno; /* Remember last error */

#ifdef MARIA_EXTERNAL_LOCKING
@@ -446,6 +448,7 @@ int _ma_mark_file_changed_now(register MARIA_SHARE *share)
*/
if (!share->temporary)
{
CRASH_IF_S3_TABLE(share);
mi_int2store(buff,share->state.open_count);
buff[2]=1; /* Mark that it's changed */
if (my_pwrite(share->kfile.file, buff, sizeof(buff),
@@ -458,6 +461,7 @@ int _ma_mark_file_changed_now(register MARIA_SHARE *share)
if (share->base.born_transactional &&
!(share->state.org_changed & STATE_NOT_MOVABLE))
{
CRASH_IF_S3_TABLE(share);
/* Lock table to current installation */
if (_ma_set_uuid(share, 0) ||
(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)
/* Its not fatal even if we couldn't get the lock ! */
if (share->state.open_count > 0)
{
CRASH_IF_S3_TABLE(share);
share->state.open_count--;
share->changed= 1; /* We have to update state */
/*
@@ -548,9 +553,15 @@ void _ma_mark_file_crashed(MARIA_SHARE *share)
{
uchar buff[2];
DBUG_ENTER("_ma_mark_file_crashed");
CRASH_IF_S3_TABLE(share);

share->state.changed|= STATE_CRASHED;
if (share->no_status_updates)
DBUG_VOID_RETURN; /* Safety */

mi_int2store(buff, share->state.changed);


/*
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
@@ -606,6 +617,7 @@ my_bool _ma_set_uuid(MARIA_SHARE *share, my_bool reset_uuid)
bzero(buff, sizeof(buff));
uuid= buff;
}
CRASH_IF_S3_TABLE(share);
return (my_bool) my_pwrite(share->kfile.file, uuid, MY_UUID_SIZE,
mi_uint2korr(share->state.header.base_pos),
MYF(MY_NABP));
@@ -787,6 +787,7 @@ typedef struct st_maria_share
my_bool changed, /* If changed since lock */
global_changed, /* If changed since open */
not_flushed;
my_bool no_status_updates; /* Set to 1 if S3 readonly table */
my_bool internal_table; /* Internal tmp table */
my_bool lock_key_trees; /* If we have to lock trees on read */
my_bool non_transactional_concurrent_insert;
@@ -1768,3 +1769,5 @@ static inline void decrement_share_in_trans(MARIA_SHARE *share)
}
C_MODE_END
#endif

#define CRASH_IF_S3_TABLE(share) DBUG_ASSERT(!share->no_status_updates)

0 comments on commit 96329d6

Please sign in to comment.