Skip to content

Commit de5646f

Browse files
committed
Prepare XtraDB to be used with xtrabackup.
The changes are deliberately kept minimal - some functions are made global instead of static (they will be used in xtrabackup later on) - functions got additional parameter, deliberately unused for now : fil_load_single_tablespaces srv_undo_tablespaces_init - Global variables added, also unused for now : srv_archive_recovery srv_archive_recovery_limit_lsn srv_apply_log_only srv_backup_mode srv_close_files - To make xtrabackup link with sql.lib on Windows, added some missing source files to sql.lib - Fixed os_thread_ret_t to be DWORD on Windows
1 parent 8f5e3e2 commit de5646f

File tree

11 files changed

+135
-17
lines changed

11 files changed

+135
-17
lines changed

sql/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ IF(SSL_DEFINES)
7777
ADD_DEFINITIONS(${SSL_DEFINES})
7878
ENDIF()
7979

80+
IF(WIN32)
81+
SET(NT_SERVICE_SOURCES nt_servc.cc nt_servc.h )
82+
ELSE()
83+
SET(NT_SERVICE_SOURCES)
84+
ENDIF()
85+
8086
SET (SQL_SOURCE
8187
../sql-common/client.c compat56.cc derror.cc des_key_file.cc
8288
discover.cc ../libmysql/errmsg.c field.cc field_conv.cc
@@ -143,6 +149,7 @@ SET (SQL_SOURCE
143149
${GEN_SOURCES}
144150
${GEN_DIGEST_SOURCES}
145151
${MYSYS_LIBWRAP_SOURCE}
152+
${NT_SERVICE_SOURCES}
146153
)
147154

148155
IF (CMAKE_SYSTEM_NAME MATCHES "Linux" OR
@@ -172,7 +179,7 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
172179
${LIBSYSTEMD})
173180

174181
IF(WIN32)
175-
SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h message.rc)
182+
SET(MYSQLD_SOURCE main.cc message.rc)
176183
TARGET_LINK_LIBRARIES(sql psapi)
177184
ELSE()
178185
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})

storage/xtradb/btr/btr0btr.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ btr_root_fseg_validate(
722722
/**************************************************************//**
723723
Gets the root node of a tree and x- or s-latches it.
724724
@return root page, x- or s-latched */
725-
static
725+
726726
buf_block_t*
727727
btr_root_block_get(
728728
/*===============*/
@@ -1531,7 +1531,7 @@ btr_node_ptr_set_child_page_no(
15311531
/************************************************************//**
15321532
Returns the child page of a node pointer and x-latches it.
15331533
@return child page, x-latched */
1534-
static
1534+
15351535
buf_block_t*
15361536
btr_node_ptr_get_child(
15371537
/*===================*/

storage/xtradb/fil/fil0fil.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ fil_node_get_space_id(
379379

380380
/*******************************************************************//**
381381
Returns the table space by a given name, NULL if not found. */
382-
UNIV_INLINE
383382
fil_space_t*
384383
fil_space_get_by_name(
385384
/*==================*/
@@ -4785,7 +4784,7 @@ directory. We retry 100 times if os_file_readdir_next_file() returns -1. The
47854784
idea is to read as much good data as we can and jump over bad data.
47864785
@return 0 if ok, -1 if error even after the retries, 1 if at the end
47874786
of the directory */
4788-
static
4787+
47894788
int
47904789
fil_file_readdir_next_file(
47914790
/*=======================*/
@@ -4826,7 +4825,7 @@ space id is != 0.
48264825
@return DB_SUCCESS or error number */
48274826
UNIV_INTERN
48284827
dberr_t
4829-
fil_load_single_table_tablespaces(void)
4828+
fil_load_single_table_tablespaces(ibool (*pred)(const char*, const char*))
48304829
/*===================================*/
48314830
{
48324831
int ret;

storage/xtradb/handler/ha_innodb.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static TYPELIB innodb_stats_method_typelib = {
284284

285285
/** Possible values for system variables "innodb_checksum_algorithm" and
286286
"innodb_log_checksum_algorithm". */
287-
static const char* innodb_checksum_algorithm_names[] = {
287+
const char* innodb_checksum_algorithm_names[] = {
288288
"CRC32",
289289
"STRICT_CRC32",
290290
"INNODB",
@@ -296,7 +296,7 @@ static const char* innodb_checksum_algorithm_names[] = {
296296

297297
/** Used to define an enumerate type of the system variables
298298
innodb_checksum_algorithm and innodb_log_checksum_algorithm. */
299-
static TYPELIB innodb_checksum_algorithm_typelib = {
299+
TYPELIB innodb_checksum_algorithm_typelib = {
300300
array_elements(innodb_checksum_algorithm_names) - 1,
301301
"innodb_checksum_algorithm_typelib",
302302
innodb_checksum_algorithm_names,
@@ -3016,7 +3016,7 @@ trx_is_started(
30163016
/****************************************************************//**
30173017
Update log_checksum_algorithm_ptr with a pointer to the function corresponding
30183018
to a given checksum algorithm. */
3019-
static
3019+
30203020
void
30213021
innodb_log_checksum_func_update(
30223022
/*============================*/

storage/xtradb/include/fil0fil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ space id is != 0.
868868
@return DB_SUCCESS or error number */
869869
UNIV_INTERN
870870
dberr_t
871-
fil_load_single_table_tablespaces(void);
871+
fil_load_single_table_tablespaces(ibool (*pred)(const char*, const char*)=0);
872872
/*===================================*/
873873
/*******************************************************************//**
874874
Returns TRUE if a single-table tablespace does not exist in the memory cache,

storage/xtradb/include/srv0srv.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ extern ulong srv_innodb_stats_method;
489489

490490
#ifdef UNIV_LOG_ARCHIVE
491491
extern ibool srv_log_archive_on;
492+
extern ibool srv_archive_recovery;
493+
extern ib_uint64_t srv_archive_recovery_limit_lsn;
492494
#endif /* UNIV_LOG_ARCHIVE */
493495

494496
extern char* srv_file_flush_method_str;
@@ -541,6 +543,11 @@ extern ulong srv_pass_corrupt_table;
541543

542544
extern ulong srv_log_checksum_algorithm;
543545

546+
extern ibool srv_apply_log_only;
547+
548+
extern ibool srv_backup_mode;
549+
extern ibool srv_close_files;
550+
544551
extern my_bool srv_force_primary_key;
545552

546553
/* Helper macro to support srv_pass_corrupt_table checks. If 'cond' is FALSE,

storage/xtradb/include/univ.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ functions. */
647647

648648
#ifdef __WIN__
649649
#define usleep(a) Sleep((a)/1000)
650-
typedef ulint os_thread_ret_t;
650+
typedef DWORD os_thread_ret_t;
651651
#define OS_THREAD_DUMMY_RETURN return(0)
652652
#else
653653
typedef void* os_thread_ret_t;

storage/xtradb/log/log0recv.cc

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ recv_synchronize_groups(
713713
/***********************************************************************//**
714714
Checks the consistency of the checkpoint info
715715
@return TRUE if ok */
716-
static
717716
ibool
718717
recv_check_cp_is_consistent(
719718
/*========================*/
@@ -743,7 +742,7 @@ recv_check_cp_is_consistent(
743742
/********************************************************//**
744743
Looks for the maximum consistent checkpoint from the log groups.
745744
@return error code or DB_SUCCESS */
746-
static MY_ATTRIBUTE((nonnull, warn_unused_result))
745+
MY_ATTRIBUTE((nonnull, warn_unused_result))
747746
dberr_t
748747
recv_find_max_checkpoint(
749748
/*=====================*/
@@ -3784,6 +3783,102 @@ recv_reset_log_files_for_backup(
37843783
}
37853784
#endif /* UNIV_HOTBACKUP */
37863785

3786+
/******************************************************//**
3787+
Checks the 4-byte checksum to the trailer checksum field of a log
3788+
block. We also accept a log block in the old format before
3789+
InnoDB-3.23.52 where the checksum field contains the log block number.
3790+
@return TRUE if ok, or if the log block may be in the format of InnoDB
3791+
version predating 3.23.52 */
3792+
UNIV_INTERN
3793+
ibool
3794+
log_block_checksum_is_ok_or_old_format(
3795+
/*===================================*/
3796+
const byte* block) /*!< in: pointer to a log block */
3797+
{
3798+
#ifdef UNIV_LOG_DEBUG
3799+
return(TRUE);
3800+
#endif /* UNIV_LOG_DEBUG */
3801+
3802+
ulint block_checksum = log_block_get_checksum(block);
3803+
3804+
if (UNIV_LIKELY(srv_log_checksum_algorithm ==
3805+
SRV_CHECKSUM_ALGORITHM_NONE ||
3806+
log_block_calc_checksum(block) == block_checksum)) {
3807+
3808+
return(TRUE);
3809+
}
3810+
3811+
if (srv_log_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32 ||
3812+
srv_log_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB ||
3813+
srv_log_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) {
3814+
3815+
const char* algo = NULL;
3816+
3817+
ib_logf(IB_LOG_LEVEL_ERROR,
3818+
"log block checksum mismatch: expected " ULINTPF ", "
3819+
"calculated checksum " ULINTPF,
3820+
block_checksum,
3821+
log_block_calc_checksum(block));
3822+
3823+
if (block_checksum == LOG_NO_CHECKSUM_MAGIC) {
3824+
3825+
algo = "none";
3826+
} else if (block_checksum ==
3827+
log_block_calc_checksum_crc32(block)) {
3828+
3829+
algo = "crc32";
3830+
} else if (block_checksum ==
3831+
log_block_calc_checksum_innodb(block)) {
3832+
3833+
algo = "innodb";
3834+
}
3835+
3836+
if (algo) {
3837+
3838+
const char* current_algo;
3839+
3840+
current_algo = buf_checksum_algorithm_name(
3841+
(srv_checksum_algorithm_t)
3842+
srv_log_checksum_algorithm);
3843+
3844+
ib_logf(IB_LOG_LEVEL_ERROR,
3845+
"current InnoDB log checksum type: %s, "
3846+
"detected log checksum type: %s",
3847+
current_algo,
3848+
algo);
3849+
}
3850+
3851+
ib_logf(IB_LOG_LEVEL_FATAL,
3852+
"STRICT method was specified for innodb_log_checksum, "
3853+
"so we intentionally assert here.");
3854+
}
3855+
3856+
ut_ad(srv_log_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_CRC32 ||
3857+
srv_log_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB);
3858+
3859+
if (block_checksum == LOG_NO_CHECKSUM_MAGIC ||
3860+
block_checksum == log_block_calc_checksum_crc32(block) ||
3861+
block_checksum == log_block_calc_checksum_innodb(block)) {
3862+
3863+
return(TRUE);
3864+
}
3865+
3866+
if (log_block_get_hdr_no(block) == block_checksum) {
3867+
3868+
/* We assume the log block is in the format of
3869+
InnoDB version < 3.23.52 and the block is ok */
3870+
#if 0
3871+
fprintf(stderr,
3872+
"InnoDB: Scanned old format < InnoDB-3.23.52"
3873+
" log block number %lu\n",
3874+
log_block_get_hdr_no(block));
3875+
#endif
3876+
return(TRUE);
3877+
}
3878+
3879+
return(FALSE);
3880+
}
3881+
37873882
void recv_dblwr_t::add(byte* page)
37883883
{
37893884
pages.push_back(page);

storage/xtradb/os/os0file.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ os_file_lock(
10101010
#ifndef UNIV_HOTBACKUP
10111011
/****************************************************************//**
10121012
Creates the seek mutexes used in positioned reads and writes. */
1013-
static
10141013
void
10151014
os_io_init_simple(void)
10161015
/*===================*/

storage/xtradb/srv/srv0srv.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ UNIV_INTERN ulong srv_read_ahead_threshold = 56;
375375

376376
#ifdef UNIV_LOG_ARCHIVE
377377
UNIV_INTERN ibool srv_log_archive_on = FALSE;
378+
UNIV_INTERN ibool srv_archive_recovery = 0;
379+
UNIV_INTERN ib_uint64_t srv_archive_recovery_limit_lsn;
378380
#endif /* UNIV_LOG_ARCHIVE */
379381

380382
/* This parameter is used to throttle the number of insert buffers that are
@@ -534,6 +536,11 @@ UNIV_INTERN ulong srv_doublewrite_batch_size = 120;
534536

535537
UNIV_INTERN ulong srv_replication_delay = 0;
536538

539+
UNIV_INTERN ibool srv_apply_log_only = FALSE;
540+
541+
UNIV_INTERN ibool srv_backup_mode = FALSE;
542+
UNIV_INTERN ibool srv_close_files = TRUE;
543+
537544
UNIV_INTERN ulong srv_pass_corrupt_table = 0; /* 0:disable 1:enable */
538545

539546
UNIV_INTERN ulong srv_log_checksum_algorithm =

0 commit comments

Comments
 (0)