Commit 24c9785a authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into bb-10.2-ext

parents 5b697c5a 40bf5c95
...@@ -2401,8 +2401,15 @@ xtrabackup_copy_logfile(copy_logfile copy) ...@@ -2401,8 +2401,15 @@ xtrabackup_copy_logfile(copy_logfile copy)
log_mutex_enter(); log_mutex_enter();
lsn_t lsn = log_group_read_log_seg(log_sys->buf, &log_sys->log, lsn_t lsn= start_lsn;
start_lsn, end_lsn); for(int retries= 0; retries < 100; retries++) {
if (log_group_read_log_seg(log_sys->buf, &log_sys->log,
&lsn, end_lsn)){
break;
}
msg("Retrying read of a redo log block");
my_sleep(1000);
}
start_lsn = xtrabackup_copy_log(copy, start_lsn, lsn); start_lsn = xtrabackup_copy_log(copy, start_lsn, lsn);
......
...@@ -3274,5 +3274,21 @@ row_number() over (partition by i order by i) i ...@@ -3274,5 +3274,21 @@ row_number() over (partition by i order by i) i
1 2 1 2
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-13384: "window" seems like a reserved column name but it's not listed as one
#
# Currently we allow window as an identifier, except for table aliases.
#
CREATE TABLE door (id INT, window VARCHAR(10));
SELECT id
FROM door as window;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'window' at line 2
SELECT id, window
FROM door;
id window
SELECT id, window
FROM door as window;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'window' at line 2
DROP TABLE door;
#
# Start of 10.3 tests # Start of 10.3 tests
# #
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
# xtrabackup backup
FOUND 1 /Invalid log block checksum/ in backup.log
INSERT INTO t VALUES(2);
# xtrabackup prepare
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * FROM t;
i
1
DROP TABLE t;
--source include/have_debug.inc
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,log_intermittent_checksum_mismatch > $backuplog;
--enable_result_log
--let SEARCH_RANGE = 10000000
--let SEARCH_PATTERN=Invalid log block checksum
--let SEARCH_FILE=$backuplog
--source include/search_pattern_in_file.inc
remove_file $backuplog;
INSERT INTO t VALUES(2);
echo # xtrabackup prepare;
--disable_result_log
exec $XTRABACKUP --prepare --target-dir=$targetdir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * FROM t;
DROP TABLE t;
rmdir $targetdir;
...@@ -2037,6 +2037,27 @@ EXECUTE stmt; ...@@ -2037,6 +2037,27 @@ EXECUTE stmt;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-13384: "window" seems like a reserved column name but it's not listed as one
--echo #
--echo # Currently we allow window as an identifier, except for table aliases.
--echo #
CREATE TABLE door (id INT, window VARCHAR(10));
--error ER_PARSE_ERROR
SELECT id
FROM door as window;
SELECT id, window
FROM door;
--error ER_PARSE_ERROR
SELECT id, window
FROM door as window;
DROP TABLE door;
--echo # --echo #
--echo # Start of 10.3 tests --echo # Start of 10.3 tests
--echo # --echo #
...@@ -1616,7 +1616,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1616,7 +1616,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
IDENT_sys TEXT_STRING_sys TEXT_STRING_literal IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
opt_component key_cache_name opt_component key_cache_name
sp_opt_label BIN_NUM TEXT_STRING_filesystem ident_or_empty sp_opt_label BIN_NUM TEXT_STRING_filesystem ident_or_empty
opt_constraint constraint opt_ident opt_constraint constraint opt_ident ident_table_alias
sp_decl_ident sp_decl_ident
sp_block_label opt_place opt_db sp_block_label opt_place opt_db
...@@ -1805,7 +1805,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1805,7 +1805,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <Lex_length_and_dec> precision opt_precision float_options %type <Lex_length_and_dec> precision opt_precision float_options
%type <symbol> keyword keyword_sp %type <symbol> keyword keyword_sp keyword_alias
keyword_sp_data_type keyword_sp_data_type
keyword_sp_not_data_type keyword_sp_not_data_type
...@@ -11611,7 +11611,7 @@ table_alias: ...@@ -11611,7 +11611,7 @@ table_alias:
opt_table_alias: opt_table_alias:
/* empty */ { $$=0; } /* empty */ { $$=0; }
| table_alias ident | table_alias ident_table_alias
{ {
$$= (LEX_CSTRING*) thd->memdup(&$2,sizeof(LEX_STRING)); $$= (LEX_CSTRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if ($$ == NULL) if ($$ == NULL)
...@@ -14528,6 +14528,16 @@ TEXT_STRING_filesystem: ...@@ -14528,6 +14528,16 @@ TEXT_STRING_filesystem:
$$.length= to.length; $$.length= to.length;
} }
} }
ident_table_alias:
IDENT_sys { $$= $1; }
| keyword_alias
{
$$.str= thd->strmake($1.str, $1.length);
if ($$.str == NULL)
MYSQL_YYABORT;
$$.length= $1.length;
}
; ;
ident: ident:
...@@ -14642,8 +14652,8 @@ user: user_maybe_role ...@@ -14642,8 +14652,8 @@ user: user_maybe_role
} }
; ;
/* Keyword that we allow for identifiers (except SP labels) */ /* Keywords which we allow as table aliases. */
keyword: keyword_alias:
keyword_sp {} keyword_sp {}
| keyword_sp_verb_clause{} | keyword_sp_verb_clause{}
| ASCII_SYM {} | ASCII_SYM {}
...@@ -14706,6 +14716,10 @@ keyword: ...@@ -14706,6 +14716,10 @@ keyword:
| UPGRADE_SYM {} | UPGRADE_SYM {}
; ;
/* Keyword that we allow for identifiers (except SP labels) */
keyword: keyword_alias | WINDOW_SYM {};
/* /*
* Keywords that we allow for labels in SPs. * Keywords that we allow for labels in SPs.
* Anything that's the beginning of a statement or characteristics * Anything that's the beginning of a statement or characteristics
......
...@@ -99,14 +99,15 @@ recv_sys_debug_free(void); ...@@ -99,14 +99,15 @@ recv_sys_debug_free(void);
/** Read a log segment to a buffer. /** Read a log segment to a buffer.
@param[out] buf buffer @param[out] buf buffer
@param[in] group redo log files @param[in] group redo log files
@param[in] start_lsn read area start @param[in, out] start_lsn in : read area start, out: the last read valid lsn
@param[in] end_lsn read area end @param[in] end_lsn read area end
@return valid end_lsn */ @param[out] invalid_block - invalid, (maybe incompletely written) block encountered
lsn_t @return false, if invalid block encountered (e.g checksum mismatch), true otherwise */
bool
log_group_read_log_seg( log_group_read_log_seg(
byte* buf, byte* buf,
const log_group_t* group, const log_group_t* group,
lsn_t start_lsn, lsn_t* start_lsn,
lsn_t end_lsn); lsn_t end_lsn);
/********************************************************//** /********************************************************//**
......
...@@ -1979,6 +1979,7 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -1979,6 +1979,7 @@ logs_empty_and_mark_files_at_shutdown(void)
goto wait_suspend_loop; goto wait_suspend_loop;
case SRV_PURGE: case SRV_PURGE:
case SRV_WORKER: case SRV_WORKER:
ut_ad(!"purge was not shut down");
srv_purge_wakeup(); srv_purge_wakeup();
thread_name = "purge thread"; thread_name = "purge thread";
goto wait_suspend_loop; goto wait_suspend_loop;
......
...@@ -608,28 +608,29 @@ recv_sys_debug_free(void) ...@@ -608,28 +608,29 @@ recv_sys_debug_free(void)
/** Read a log segment to a buffer. /** Read a log segment to a buffer.
@param[out] buf buffer @param[out] buf buffer
@param[in] group redo log files @param[in] group redo log files
@param[in] start_lsn read area start @param[in, out] start_lsn in : read area start, out: the last read valid lsn
@param[in] end_lsn read area end @param[in] end_lsn read area end
@return valid end_lsn */ @param[out] invalid_block - invalid, (maybe incompletely written) block encountered
lsn_t @return false, if invalid block encountered (e.g checksum mismatch), true otherwise */
bool
log_group_read_log_seg( log_group_read_log_seg(
byte* buf, byte* buf,
const log_group_t* group, const log_group_t* group,
lsn_t start_lsn, lsn_t *start_lsn,
lsn_t end_lsn) lsn_t end_lsn)
{ {
ulint len; ulint len;
lsn_t source_offset; lsn_t source_offset;
bool success = true;
ut_ad(log_mutex_own()); ut_ad(log_mutex_own());
ut_ad(!(start_lsn % OS_FILE_LOG_BLOCK_SIZE)); ut_ad(!(*start_lsn % OS_FILE_LOG_BLOCK_SIZE));
ut_ad(!(end_lsn % OS_FILE_LOG_BLOCK_SIZE)); ut_ad(!(end_lsn % OS_FILE_LOG_BLOCK_SIZE));
loop: loop:
source_offset = log_group_calc_lsn_offset(start_lsn, group); source_offset = log_group_calc_lsn_offset(*start_lsn, group);
ut_a(end_lsn - start_lsn <= ULINT_MAX); ut_a(end_lsn - *start_lsn <= ULINT_MAX);
len = (ulint) (end_lsn - start_lsn); len = (ulint) (end_lsn - *start_lsn);
ut_ad(len != 0); ut_ad(len != 0);
...@@ -659,16 +660,16 @@ log_group_read_log_seg( ...@@ -659,16 +660,16 @@ log_group_read_log_seg(
for (ulint l = 0; l < len; l += OS_FILE_LOG_BLOCK_SIZE, for (ulint l = 0; l < len; l += OS_FILE_LOG_BLOCK_SIZE,
buf += OS_FILE_LOG_BLOCK_SIZE, buf += OS_FILE_LOG_BLOCK_SIZE,
start_lsn += OS_FILE_LOG_BLOCK_SIZE) { (*start_lsn) += OS_FILE_LOG_BLOCK_SIZE) {
const ulint block_number = log_block_get_hdr_no(buf); const ulint block_number = log_block_get_hdr_no(buf);
if (block_number != log_block_convert_lsn_to_no(start_lsn)) { if (block_number != log_block_convert_lsn_to_no(*start_lsn)) {
/* Garbage or an incompletely written log block. /* Garbage or an incompletely written log block.
We will not report any error, because this can We will not report any error, because this can
happen when InnoDB was killed while it was happen when InnoDB was killed while it was
writing redo log. We simply treat this as an writing redo log. We simply treat this as an
abrupt end of the redo log. */ abrupt end of the redo log. */
end_lsn = start_lsn; end_lsn = *start_lsn;
break; break;
} }
...@@ -676,6 +677,13 @@ log_group_read_log_seg( ...@@ -676,6 +677,13 @@ log_group_read_log_seg(
ulint crc = log_block_calc_checksum_crc32(buf); ulint crc = log_block_calc_checksum_crc32(buf);
ulint cksum = log_block_get_checksum(buf); ulint cksum = log_block_get_checksum(buf);
DBUG_EXECUTE_IF("log_intermittent_checksum_mismatch", {
static int block_counter;
if (block_counter++ == 0) {
cksum = crc + 1;
}
});
if (crc != cksum) { if (crc != cksum) {
ib::error() << "Invalid log block checksum." ib::error() << "Invalid log block checksum."
<< " block: " << block_number << " block: " << block_number
...@@ -683,30 +691,33 @@ log_group_read_log_seg( ...@@ -683,30 +691,33 @@ log_group_read_log_seg(
<< log_block_get_checkpoint_no(buf) << log_block_get_checkpoint_no(buf)
<< " expected: " << crc << " expected: " << crc
<< " found: " << cksum; << " found: " << cksum;
end_lsn = start_lsn; end_lsn = *start_lsn;
success = false;
break; break;
} }
if (group->is_encrypted()) { if (group->is_encrypted()) {
log_crypt(buf, start_lsn, log_crypt(buf, *start_lsn,
OS_FILE_LOG_BLOCK_SIZE, true); OS_FILE_LOG_BLOCK_SIZE, true);
} }
} }
} }
if (recv_sys->report(ut_time())) { if (recv_sys->report(ut_time())) {
ib::info() << "Read redo log up to LSN=" << start_lsn; ib::info() << "Read redo log up to LSN=" << *start_lsn;
sd_notifyf(0, "STATUS=Read redo log up to LSN=" LSN_PF, sd_notifyf(0, "STATUS=Read redo log up to LSN=" LSN_PF,
start_lsn); *start_lsn);
} }
if (start_lsn != end_lsn) { if (*start_lsn != end_lsn) {
goto loop; goto loop;
} }
return(start_lsn); return(success);
} }
/********************************************************//** /********************************************************//**
Copies a log segment from the most up-to-date log group to the other log Copies a log segment from the most up-to-date log group to the other log
groups, so that they all contain the latest log data. Also writes the info groups, so that they all contain the latest log data. Also writes the info
...@@ -721,10 +732,10 @@ recv_synchronize_groups() ...@@ -721,10 +732,10 @@ recv_synchronize_groups()
/* Read the last recovered log block to the recovery system buffer: /* Read the last recovered log block to the recovery system buffer:
the block is always incomplete */ the block is always incomplete */
const lsn_t start_lsn = ut_uint64_align_down(recovered_lsn, lsn_t start_lsn = ut_uint64_align_down(recovered_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
log_group_read_log_seg(log_sys->buf, &log_sys->log, log_group_read_log_seg(log_sys->buf, &log_sys->log,
start_lsn, start_lsn + OS_FILE_LOG_BLOCK_SIZE); &start_lsn, start_lsn + OS_FILE_LOG_BLOCK_SIZE);
/* Update the fields in the group struct to correspond to /* Update the fields in the group struct to correspond to
recovered_lsn */ recovered_lsn */
...@@ -2903,8 +2914,9 @@ recv_group_scan_log_recs( ...@@ -2903,8 +2914,9 @@ recv_group_scan_log_recs(
start_lsn = ut_uint64_align_down(end_lsn, start_lsn = ut_uint64_align_down(end_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
end_lsn = log_group_read_log_seg( end_lsn = start_lsn;
log_sys->buf, group, start_lsn, log_group_read_log_seg(
log_sys->buf, group, &end_lsn,
start_lsn + RECV_SCAN_SIZE); start_lsn + RECV_SCAN_SIZE);
} while (end_lsn != start_lsn } while (end_lsn != start_lsn
&& !recv_scan_log_recs( && !recv_scan_log_recs(
......
...@@ -2980,8 +2980,11 @@ srv_purge_wakeup() ...@@ -2980,8 +2980,11 @@ srv_purge_wakeup()
{ {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
if (srv_force_recovery < SRV_FORCE_NO_BACKGROUND) { if (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND) {
return;
}
do {
srv_release_threads(SRV_PURGE, 1); srv_release_threads(SRV_PURGE, 1);
if (srv_n_purge_threads > 1) { if (srv_n_purge_threads > 1) {
...@@ -2989,7 +2992,9 @@ srv_purge_wakeup() ...@@ -2989,7 +2992,9 @@ srv_purge_wakeup()
srv_release_threads(SRV_WORKER, n_workers); srv_release_threads(SRV_WORKER, n_workers);
} }
} } while (!srv_running
&& (srv_sys.n_threads_active[SRV_WORKER]
|| srv_sys.n_threads_active[SRV_PURGE]));
} }
/** Check if tablespace is being truncated. /** Check if tablespace is being truncated.
......
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