mirror of
https://github.com/MariaDB/server.git
synced 2026-05-07 23:54:31 +02:00
Copied recent improvements for MyISAM to Aria
- data files will be opened in readonly mode for repair if --quick is used. - Added information about check progress if --verbose is used. - Added new option --keys-active= as a simpler version of keys-used. Internal changes: - Store open file mode in share->index_mode and share->data_mode instead of in share->mode. - Removed not needed 'mode' argument from maria_clone_internal()
This commit is contained in:
parent
6a4fe9923d
commit
24821e9585
6 changed files with 101 additions and 28 deletions
|
|
@ -248,7 +248,7 @@ enum options_mc {
|
|||
OPT_MAX_RECORD_LENGTH, OPT_AUTO_CLOSE, OPT_STATS_METHOD, OPT_TRANSACTION_LOG,
|
||||
OPT_ZEROFILL_KEEP_LSN,
|
||||
OPT_REQUIRE_CONTROL_FILE, OPT_IGNORE_CONTROL_FILE,
|
||||
OPT_LOG_DIR, OPT_WARNING_FOR_WRONG_TRANSID
|
||||
OPT_LOG_DIR, OPT_WARNING_FOR_WRONG_TRANSID,OPT_ACTIVE_KEYS
|
||||
};
|
||||
|
||||
static struct my_option my_long_options[] =
|
||||
|
|
@ -319,10 +319,16 @@ static struct my_option my_long_options[] =
|
|||
(uchar**)&opt_ignore_control_file, 0, 0, GET_BOOL, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"keys-used", 'k',
|
||||
"Tell Aria to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts.",
|
||||
"Tell Aria to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts. See also keys-active",
|
||||
&check_param.keys_in_use,
|
||||
&check_param.keys_in_use,
|
||||
0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0},
|
||||
{"keys-active", OPT_ACTIVE_KEYS,
|
||||
"Threat all not listed keys as disabled. If used with repair, the keys "
|
||||
"will be disabled permanently. The argument is a list of key numbers, "
|
||||
"starting from 1, separated by ','. "
|
||||
"keys-active and keys-used are two ways to do the same thing",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"datadir", 'h',
|
||||
"Path for control file (and logs if --logdir not used).",
|
||||
(char**) &maria_data_root, 0, 0, GET_STR, REQUIRED_ARG,
|
||||
|
|
@ -455,7 +461,7 @@ static struct my_option my_long_options[] =
|
|||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{ "stats_method", OPT_STATS_METHOD,
|
||||
"Specifies how index statistics collection code should treat NULLs. "
|
||||
"Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), "
|
||||
"Possible values of name are \"nulls_unequal\" (default behavior for MySQL 4.1/5.0), "
|
||||
"\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".",
|
||||
(char**) &maria_stats_method_str, (char**) &maria_stats_method_str, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
|
|
@ -472,7 +478,7 @@ static struct my_option my_long_options[] =
|
|||
|
||||
static void print_version(void)
|
||||
{
|
||||
printf("%s Ver 1.3 for %s on %s\n", my_progname, SYSTEM_TYPE,
|
||||
printf("%s Ver 1.4 for %s on %s\n", my_progname, SYSTEM_TYPE,
|
||||
MACHINE_TYPE);
|
||||
}
|
||||
|
||||
|
|
@ -566,6 +572,11 @@ Recover (repair)/ options (When using '--recover' or '--safe-recover'):\n\
|
|||
-k, --keys-used=# Tell Aria to update only some specific keys. # is a\n\
|
||||
bit mask of which keys to use. This can be used to\n\
|
||||
get faster inserts.\n\
|
||||
--keys-active\n\
|
||||
Treat all not listed keys as disabled. If used with repair, the keys\n\
|
||||
will be disabled permanently. The argument is a list of key numbers,\n\
|
||||
starting from 1, separated by ','\n\
|
||||
keys-active and keys-used are two ways to do the same thing\n\
|
||||
--max-record-length=#\n\
|
||||
Skip rows bigger than this if aria_chk can't allocate\n\
|
||||
memory to hold it.\n\
|
||||
|
|
@ -750,6 +761,32 @@ get_one_option(const struct my_option *opt,
|
|||
case 'k':
|
||||
check_param.keys_in_use= (ulonglong) strtoll(argument, NULL, 10);
|
||||
break;
|
||||
case OPT_ACTIVE_KEYS:
|
||||
if (argument == disabled_my_option)
|
||||
check_param.keys_in_use= ~0LL;
|
||||
else
|
||||
{
|
||||
const char *start;
|
||||
char *end, *str_end= strend(argument);
|
||||
check_param.keys_in_use= 0;
|
||||
for (start= argument; *start ; start= end)
|
||||
{
|
||||
int error;
|
||||
longlong key;
|
||||
end= str_end;
|
||||
key= my_strtoll10(start, &end, &error);
|
||||
if (error || key > 64 || (*end && *end != ','))
|
||||
{
|
||||
fprintf(stderr, "Wrong argument to active-keys. Expected a list of "
|
||||
"numbers like 1,2,3,4\n");
|
||||
exit(1); /* Change to my_exit after merge */
|
||||
}
|
||||
check_param.keys_in_use|= 1LL << (key-1);
|
||||
if (*end == ',')
|
||||
end++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if (argument == disabled_my_option)
|
||||
check_param.testflag&= ~T_MEDIUM;
|
||||
|
|
@ -1032,7 +1069,9 @@ static int maria_chk(HA_CHECK *param, char *filename)
|
|||
if (!(info=maria_open(filename,
|
||||
(param->testflag & (T_DESCRIPT | T_READONLY)) ?
|
||||
O_RDONLY : O_RDWR,
|
||||
HA_OPEN_FOR_REPAIR |
|
||||
HA_OPEN_FOR_REPAIR | HA_OPEN_FORCE_MODE |
|
||||
((param->testflag & T_QUICK) ?
|
||||
HA_OPEN_DATA_READONLY : 0) |
|
||||
((param->testflag & T_WAIT_FOREVER) ?
|
||||
HA_OPEN_WAIT_IF_LOCKED :
|
||||
(param->testflag & T_DESCRIPT) ?
|
||||
|
|
@ -1160,6 +1199,13 @@ static int maria_chk(HA_CHECK *param, char *filename)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't allow disable of active auto_increment keys for repair */
|
||||
if (share->base.auto_key &&
|
||||
(share->state.key_map & (1LL << share->base.auto_key)) &&
|
||||
param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
|
||||
check_param.keys_in_use|= (1LL << share->base.auto_key);
|
||||
|
||||
if ((param->testflag & (T_REP_ANY | T_STATISTICS |
|
||||
T_SORT_RECORDS | T_SORT_INDEX)) &&
|
||||
(((param->testflag & T_UNPACK) &&
|
||||
|
|
|
|||
|
|
@ -594,6 +594,11 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
|
|||
param->max_level=0;
|
||||
if (chk_index(param, info,keyinfo, &page, &keys, param->key_crc+key,1))
|
||||
DBUG_RETURN(-1);
|
||||
if ((param->testflag & T_WRITE_LOOP) && param->verbose)
|
||||
{
|
||||
puts(" \r");
|
||||
fflush(stdout);
|
||||
}
|
||||
if (!(keyinfo->flag & (HA_FULLTEXT | HA_SPATIAL | HA_RTREE_INDEX)))
|
||||
{
|
||||
if (keys != share->state.state.records)
|
||||
|
|
@ -695,7 +700,8 @@ do_stat:
|
|||
puts("");
|
||||
}
|
||||
if (param->key_file_blocks != share->state.state.key_file_length &&
|
||||
share->state.key_map == ~(ulonglong) 0)
|
||||
maria_is_all_keys_active(share->state.key_map, share->base.keys) &&
|
||||
!full_text_keys)
|
||||
_ma_check_print_warning(param, "Some data are unreferenced in keyfile");
|
||||
if (found_keys != full_text_keys)
|
||||
param->record_checksum=old_record_checksum-init_checksum; /* Remove delete links */
|
||||
|
|
@ -1089,6 +1095,15 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
|
|||
goto err;
|
||||
}
|
||||
param->record_checksum+= (ha_checksum) record;
|
||||
if ((param->testflag & T_WRITE_LOOP) && param->verbose &&
|
||||
(*keys % WRITE_COUNT) == 0)
|
||||
{
|
||||
char llbuff[22];
|
||||
ulonglong records= info->state->records;
|
||||
printf("%15s (%3.4f%%)\r", llstr(*keys, llbuff),
|
||||
((double) *keys / (records > *keys ? records : *keys)) *100);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
if (keypos != endpos)
|
||||
{
|
||||
|
|
@ -5721,6 +5736,7 @@ static int sort_key_write(MARIA_SORT_PARAM *sort_param, const uchar *a)
|
|||
{
|
||||
_ma_check_print_error(param,
|
||||
"Internal error: Keys are not in order from sort");
|
||||
DBUG_ASSERT(0);
|
||||
return(1);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -790,7 +790,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
|
|||
MARIA_SHARE *share= info->s;
|
||||
/* the first three variables below can never change */
|
||||
if (share->base.born_transactional && !share->temporary &&
|
||||
share->mode != O_RDONLY &&
|
||||
(share->index_mode != O_RDONLY && share->data_mode != O_RDONLY) &&
|
||||
!(share->in_checkpoint & MARIA_CHECKPOINT_SEEN_IN_LOOP))
|
||||
{
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ my_bool _ma_dynmap_file(MARIA_HA *info, my_off_t size)
|
|||
*/
|
||||
info->s->file_map= (uchar*)
|
||||
my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
|
||||
info->s->mode==O_RDONLY ? PROT_READ :
|
||||
info->s->index_mode==O_RDONLY ? PROT_READ :
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_NORESERVE,
|
||||
info->dfile.file, 0L);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ MARIA_HA *_ma_test_if_reopen(const char *filename)
|
|||
SYNOPSIS
|
||||
maria_clone_internal()
|
||||
share Share of already open table
|
||||
mode Mode of table (O_RDONLY | O_RDWR)
|
||||
data_file Filedescriptor of data file to use < 0 if one should open
|
||||
open it.
|
||||
internal_table <> 0 if this is an internal temporary table
|
||||
|
|
@ -86,7 +85,7 @@ MARIA_HA *_ma_test_if_reopen(const char *filename)
|
|||
*/
|
||||
|
||||
static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
|
||||
int mode, File data_file,
|
||||
File data_file,
|
||||
uint internal_table,
|
||||
struct ms3_st *s3)
|
||||
{
|
||||
|
|
@ -100,11 +99,6 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
|
|||
errpos= 0;
|
||||
bzero((uchar*) &info,sizeof(info));
|
||||
|
||||
if (mode == O_RDWR && share->mode == O_RDONLY)
|
||||
{
|
||||
my_errno=EACCES; /* Can't open in write mode */
|
||||
goto err;
|
||||
}
|
||||
if (data_file >= 0)
|
||||
info.dfile.file= data_file;
|
||||
else if (_ma_open_datafile(&info, share))
|
||||
|
|
@ -261,7 +255,8 @@ err:
|
|||
MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
|
||||
S3_INFO *s3)
|
||||
{
|
||||
int open_mode= 0,save_errno;
|
||||
int save_errno;
|
||||
int open_mode, try_open_mode;
|
||||
uint i,j,len,errpos,head_length,base_pos,keys, realpath_err,
|
||||
key_parts,base_key_parts,unique_key_parts,fulltext_keys,uniques;
|
||||
uint internal_table= MY_TEST(open_flags & HA_OPEN_INTERNAL_TABLE);
|
||||
|
|
@ -345,14 +340,24 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
|
|||
goto err;
|
||||
});
|
||||
DEBUG_SYNC_C("mi_open_kfile");
|
||||
|
||||
/*
|
||||
We first try to open the file on read-write mode to ensure
|
||||
that the table is usable for future read and write queries in
|
||||
MariaDB. Only if the read-write mode fails we try to readonly.
|
||||
*/
|
||||
try_open_mode= (open_flags & HA_OPEN_FORCE_MODE) ? mode : O_RDWR;
|
||||
|
||||
if ((kfile=mysql_file_open(key_file_kfile, name_buff,
|
||||
(open_mode=O_RDWR) | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
|
||||
(open_mode=try_open_mode) | O_SHARE |
|
||||
O_NOFOLLOW | O_CLOEXEC,
|
||||
MYF(common_flag | MY_NOSYMLINKS))) < 0)
|
||||
{
|
||||
if ((errno != EROFS && errno != EACCES) ||
|
||||
if ((errno != EROFS && errno != EACCES) || open_mode == O_RDONLY ||
|
||||
mode != O_RDONLY ||
|
||||
(kfile=mysql_file_open(key_file_kfile, name_buff,
|
||||
(open_mode=O_RDONLY) | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
|
||||
(open_mode=O_RDONLY) | O_SHARE |
|
||||
O_NOFOLLOW | O_CLOEXEC,
|
||||
MYF(common_flag | MY_NOSYMLINKS))) < 0)
|
||||
goto err;
|
||||
}
|
||||
|
|
@ -400,7 +405,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
|
|||
}
|
||||
#endif /* WITH_S3_STORAGE_ENGINE */
|
||||
|
||||
share->mode=open_mode;
|
||||
share->index_mode= share->data_mode= open_mode;
|
||||
if (open_flags & HA_OPEN_DATA_READONLY)
|
||||
share->data_mode= O_RDONLY;
|
||||
if (memcmp(share->state.header.file_version, maria_file_magic, 4))
|
||||
{
|
||||
DBUG_PRINT("error",("Wrong header in %s",name_buff));
|
||||
|
|
@ -447,7 +454,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
|
|||
my_errno= HA_WRONG_CREATE_OPTION;
|
||||
goto err;
|
||||
}
|
||||
share->mode|= O_NOFOLLOW; /* all symlinks are resolved by realpath() */
|
||||
/* all symlinks are resolved by realpath() */
|
||||
share->index_mode|= O_NOFOLLOW;
|
||||
share->data_mode|= O_NOFOLLOW;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1171,7 +1180,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
|
|||
s3f.free(&index_header);
|
||||
#endif /* WITH_S3_STORAGE_ENGINE */
|
||||
|
||||
if (!(m_info= maria_clone_internal(share, mode, data_file,
|
||||
if (!(m_info= maria_clone_internal(share, data_file,
|
||||
internal_table, s3_client)))
|
||||
goto err;
|
||||
|
||||
|
|
@ -2053,12 +2062,12 @@ void _ma_set_index_pagecache_callbacks(PAGECACHE_FILE *file,
|
|||
|
||||
int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share)
|
||||
{
|
||||
myf flags= ((share->mode & O_NOFOLLOW) ? MY_NOSYMLINKS | MY_WME : MY_WME) |
|
||||
share->malloc_flag;
|
||||
myf flags= ((share->data_mode & O_NOFOLLOW) ?
|
||||
MY_NOSYMLINKS | MY_WME : MY_WME) | share->malloc_flag;
|
||||
DEBUG_SYNC_C("mi_open_datafile");
|
||||
info->dfile.file= share->bitmap.file.file=
|
||||
mysql_file_open(key_file_dfile, share->data_file_name.str,
|
||||
share->mode | O_SHARE | O_CLOEXEC, flags);
|
||||
share->data_mode | O_SHARE | O_CLOEXEC, flags);
|
||||
return info->dfile.file >= 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
|
|
@ -2072,8 +2081,9 @@ int _ma_open_keyfile(MARIA_SHARE *share)
|
|||
mysql_mutex_lock(&share->intern_lock);
|
||||
share->kfile.file= mysql_file_open(key_file_kfile,
|
||||
share->unique_file_name.str,
|
||||
share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
|
||||
MYF(MY_WME | MY_NOSYMLINKS));
|
||||
share->index_mode | O_SHARE | O_NOFOLLOW |
|
||||
O_CLOEXEC,
|
||||
MYF(MY_WME | MY_NOSYMLINKS));
|
||||
mysql_mutex_unlock(&share->intern_lock);
|
||||
return (share->kfile.file < 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -765,7 +765,8 @@ typedef struct st_maria_share
|
|||
PAGECACHE_FILE kfile; /* Shared keyfile */
|
||||
S3_INFO *s3_path; /* Connection and path in s3 */
|
||||
File data_file; /* Shared data file */
|
||||
int mode; /* mode of file on open */
|
||||
int index_mode; /* mode on index file on open */
|
||||
int data_mode; /* mode of data file on open */
|
||||
uint reopen; /* How many times opened */
|
||||
uint in_trans; /* Number of references by trn */
|
||||
uint w_locks, r_locks, tot_locks; /* Number of read/write locks */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue