Commit 8f33f49e authored by Monty's avatar Monty

Aria: Add transaction id to log of create table

In the case of a crash directly after a creation of an Aria table,
Aria recovery would think that the table was from another system and
require a repair of the table and inform that the table is 'zerofilled".
This would cause no harm, but was confusing to see when testing atomic
alter table.

Fixed by logging the create transaction id to the log.

Other things:
- Added "show table status from sys" to maria_empy_logs. This ensures one
  does not get any zerofill warnings when sys/sys_config is used by other
  tests.
- aria_chk --describe now prints a warning if the table was moved from
  another system.
- Logging of truncate (maria_delete_all_rows) is changed to use the
  current trid for the create table.
  This is to ensure that we do not run into the same problem with truncate.
- Changed back sys_config table to Aria as this patch should fix the
  "zerofill" problem in buildbot.
- Added scripts/mysql_sys_schema.sql to .gitignore
parent 1055cf96
...@@ -138,6 +138,7 @@ scripts/maria_add_gis_sp_bootstrap.sql ...@@ -138,6 +138,7 @@ scripts/maria_add_gis_sp_bootstrap.sql
scripts/galera_new_cluster scripts/galera_new_cluster
scripts/galera_recovery scripts/galera_recovery
scripts/mysql_convert_table_format.pl scripts/mysql_convert_table_format.pl
scripts/mysql_sys_schema.sql
scripts/mysqld_multi.pl scripts/mysqld_multi.pl
scripts/mysqldumpslow.pl scripts/mysqldumpslow.pl
scripts/mysqlhotcopy.pl scripts/mysqlhotcopy.pl
......
...@@ -94,13 +94,15 @@ eval use $default_db; ...@@ -94,13 +94,15 @@ eval use $default_db;
--enable_query_log --enable_query_log
# #
# Ensure that we don't get warnings from mysql.priv (used by check_mysqld) # Ensure that we don't get warnings from mysql.priv (used by check_mysqld),
# or test running after this one. # sys_config or from test running after this one.
# #
--disable_query_log --disable_query_log
--disable_warnings --disable_warnings
--disable_result_log --disable_result_log
# Zerofill all Aria tables in mysql and sys
show table status from mysql; show table status from mysql;
show table status from sys;
--enable_result_log --enable_result_log
--enable_warnings --enable_warnings
--enable_query_log --enable_query_log
...@@ -24,6 +24,6 @@ CREATE TABLE IF NOT EXISTS sys_config ( ...@@ -24,6 +24,6 @@ CREATE TABLE IF NOT EXISTS sys_config (
value VARCHAR(128), value VARCHAR(128),
set_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, set_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
set_by VARCHAR(128) set_by VARCHAR(128)
) ENGINE = MyISAM; ) ENGINE = Aria;
...@@ -1588,6 +1588,12 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name) ...@@ -1588,6 +1588,12 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name)
buff[MY_UUID_STRING_LENGTH]= 0; buff[MY_UUID_STRING_LENGTH]= 0;
my_uuid2str(share->base.uuid, buff); my_uuid2str(share->base.uuid, buff);
printf("UUID: %s\n", buff); printf("UUID: %s\n", buff);
if (ma_control_file_inited() &&
memcmp(share->base.uuid, maria_uuid, MY_UUID_SIZE))
printf("Warning: File UUID not match control file UUID! "
"File is probably moved\n"
"It will be updated to new system on first usage if zerofill is "
"not done\n");
pos=buff; pos=buff;
if (share->state.changed & STATE_CRASHED) if (share->state.changed & STATE_CRASHED)
strmov(buff, share->state.changed & STATE_CRASHED_ON_REPAIR ? strmov(buff, share->state.changed & STATE_CRASHED_ON_REPAIR ?
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <my_bit.h> #include <my_bit.h>
#include "ma_blockrec.h" #include "ma_blockrec.h"
#include "trnman_public.h" #include "trnman_public.h"
#include "trnman.h"
#include "ma_crypt.h" #include "ma_crypt.h"
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
...@@ -82,6 +83,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -82,6 +83,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
enum en_fieldtype type; enum en_fieldtype type;
enum data_file_type org_datafile_type= datafile_type; enum data_file_type org_datafile_type= datafile_type;
MARIA_SHARE share; MARIA_SHARE share;
TRN tmp_transaction_object;
MARIA_KEYDEF *keydef,tmp_keydef; MARIA_KEYDEF *keydef,tmp_keydef;
MARIA_UNIQUEDEF *uniquedef; MARIA_UNIQUEDEF *uniquedef;
HA_KEYSEG *keyseg,tmp_keyseg; HA_KEYSEG *keyseg,tmp_keyseg;
...@@ -1084,7 +1086,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -1084,7 +1086,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
{ {
/* /*
we log the first bytes and then the size to which we extend; this is we log the first bytes and then the size to which we extend; this is
not log 1 KB of mostly zeroes if this is a small table. a log of about 1 KB of mostly zeroes if this is a small table.
*/ */
char empty_string[]= ""; char empty_string[]= "";
LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4];
...@@ -1149,9 +1151,10 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -1149,9 +1151,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
called external_lock(), so have no TRN. It does not matter, as all called external_lock(), so have no TRN. It does not matter, as all
these operations are non-transactional and sync their files. these operations are non-transactional and sync their files.
*/ */
trnman_init_tmp_trn_for_logging_trid(&tmp_transaction_object);
if (unlikely(translog_write_record(&lsn, if (unlikely(translog_write_record(&lsn,
LOGREC_REDO_CREATE_TABLE, LOGREC_REDO_CREATE_TABLE,
&dummy_transaction_object, NULL, &tmp_transaction_object, NULL,
total_rec_length, total_rec_length,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL, NULL) || log_array, NULL, NULL) ||
...@@ -1172,7 +1175,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -1172,7 +1175,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
store LSN into file, needed for Recovery to not be confused if a store LSN into file, needed for Recovery to not be confused if a
DROP+CREATE happened (applying REDOs to the wrong table). DROP+CREATE happened (applying REDOs to the wrong table).
*/ */
if (_ma_update_state_lsns_sub(&share, lsn, trnman_get_min_safe_trid(), if (_ma_update_state_lsns_sub(&share, lsn, tmp_transaction_object.trid,
FALSE, TRUE)) FALSE, TRUE))
goto err; goto err;
my_free(log_data); my_free(log_data);
......
...@@ -131,7 +131,7 @@ int maria_delete_all_rows(MARIA_HA *info) ...@@ -131,7 +131,7 @@ int maria_delete_all_rows(MARIA_HA *info)
my_bool error= _ma_state_info_write(share, my_bool error= _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET | MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_LOCK) || MA_STATE_INFO_WRITE_LOCK) ||
_ma_update_state_lsns(share, lsn, trnman_get_min_trid(), FALSE, FALSE) || _ma_update_state_lsns(share, lsn, info->trn->trid, FALSE, FALSE) ||
_ma_sync_table_files(info); _ma_sync_table_files(info);
info->trn->rec_lsn= LSN_IMPOSSIBLE; info->trn->rec_lsn= LSN_IMPOSSIBLE;
if (error) if (error)
......
...@@ -568,8 +568,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, ...@@ -568,8 +568,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
memcmp(share->base.uuid, maria_uuid, MY_UUID_SIZE)))))) memcmp(share->base.uuid, maria_uuid, MY_UUID_SIZE))))))
{ {
DBUG_PRINT("warning", ("table is moved from another system. uuid_diff: %d create_trid: %lu max_trid: %lu", DBUG_PRINT("warning", ("table is moved from another system. uuid_diff: %d create_trid: %lu max_trid: %lu",
memcmp(share->base.uuid, maria_uuid, memcmp(share->base.uuid, maria_uuid,
MY_UUID_SIZE) != 0, MY_UUID_SIZE) != 0,
(ulong) share->state.create_trid, (ulong) share->state.create_trid,
(ulong) trnman_get_max_trid())); (ulong) trnman_get_max_trid()));
if (open_flags & HA_OPEN_FOR_REPAIR) if (open_flags & HA_OPEN_FOR_REPAIR)
......
...@@ -194,6 +194,7 @@ int trnman_init(TrID initial_trid) ...@@ -194,6 +194,7 @@ int trnman_init(TrID initial_trid)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* /*
NOTE NOTE
this could only be called in the "idle" state - no transaction can be this could only be called in the "idle" state - no transaction can be
...@@ -229,6 +230,7 @@ void trnman_destroy() ...@@ -229,6 +230,7 @@ void trnman_destroy()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* /*
NOTE NOTE
TrID is limited to 6 bytes. Initial value of the generator TrID is limited to 6 bytes. Initial value of the generator
...@@ -267,7 +269,7 @@ static uint get_short_trid(TRN *trn) ...@@ -267,7 +269,7 @@ static uint get_short_trid(TRN *trn)
} }
/** /**
Allocates and initialzies a new TRN object Allocates and initializes a new TRN object
@note the 'wt' parameter can only be 0 in a single-threaded code (or, @note the 'wt' parameter can only be 0 in a single-threaded code (or,
generally, where threads cannot block each other), otherwise the generally, where threads cannot block each other), otherwise the
...@@ -384,6 +386,26 @@ TRN *trnman_new_trn(WT_THD *wt) ...@@ -384,6 +386,26 @@ TRN *trnman_new_trn(WT_THD *wt)
DBUG_RETURN(trn); DBUG_RETURN(trn);
} }
/*
Initialize a temporary TRN object for logging a new transaction id (trid)
to it. Used by create table to associate a create trid to the table.
Out: trn->trid is updated with next available trid
*/
void trnman_init_tmp_trn_for_logging_trid(TRN *trn)
{
*trn= dummy_transaction_object;
/* Avoid logging short_id */
trn->short_id= 1;
/* Trid gets logged in translog_write_record */
trn->first_undo_lsn= 0;
/* Get next free trid */
trn->trid= trnman_get_min_safe_trid();
}
/* /*
remove a trn from the active list. remove a trn from the active list.
if necessary - move to committed list and set commit_trid if necessary - move to committed list and set commit_trid
......
...@@ -58,6 +58,7 @@ uint trnman_has_locked_tables(TRN *trn); ...@@ -58,6 +58,7 @@ uint trnman_has_locked_tables(TRN *trn);
void trnman_reset_locked_tables(TRN *trn, uint locked_tables); void trnman_reset_locked_tables(TRN *trn, uint locked_tables);
TRN *trnman_recreate_trn_from_recovery(uint16 shortid, TrID longid); TRN *trnman_recreate_trn_from_recovery(uint16 shortid, TrID longid);
TRN *trnman_get_any_trn(void); TRN *trnman_get_any_trn(void);
void trnman_init_tmp_trn_for_logging_trid(TRN *trn);
TrID trnman_get_min_trid(void); TrID trnman_get_min_trid(void);
TrID trnman_get_max_trid(void); TrID trnman_get_max_trid(void);
TrID trnman_get_min_safe_trid(); TrID trnman_get_min_safe_trid();
......
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