foo2
sql/ha_innodb.cc: Import patch foo2 sql/ha_innodb.h: Import patch foo2 sql/handler.cc: Import patch foo2 sql/handler.h: Import patch foo2 sql/mysqld.cc: Import patch foo2 sql/set_var.cc: Import patch foo2 sql/sql_class.h: Import patch foo2 sql/sql_repl.cc: Import patch foo2
This commit is contained in:
parent
ce33555014
commit
365f6f6f03
231
sql/ha_innodb.cc
231
sql/ha_innodb.cc
@ -1741,25 +1741,6 @@ innobase_report_binlog_offset_and_commit(
|
||||
trx->mysql_log_file_name = log_file_name;
|
||||
trx->mysql_log_offset = (ib_longlong)end_offset;
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
if (thd->variables.sync_replication) {
|
||||
/* Let us store the binlog file name and the position, so that
|
||||
we know how long to wait for the binlog to the replicated to
|
||||
the slave in synchronous replication. */
|
||||
|
||||
if (trx->repl_wait_binlog_name == NULL) {
|
||||
|
||||
trx->repl_wait_binlog_name =
|
||||
(char*)mem_alloc_noninline(FN_REFLEN + 100);
|
||||
}
|
||||
|
||||
ut_a(strlen(log_file_name) < FN_REFLEN + 100);
|
||||
|
||||
strcpy(trx->repl_wait_binlog_name, log_file_name);
|
||||
|
||||
trx->repl_wait_binlog_pos = (ib_longlong)end_offset;
|
||||
}
|
||||
#endif /* HAVE_REPLICATION */
|
||||
trx->flush_log_later = TRUE;
|
||||
|
||||
innobase_commit(thd, TRUE);
|
||||
@ -1828,219 +1809,9 @@ innobase_commit_complete(
|
||||
trx_commit_complete_for_mysql(trx);
|
||||
}
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
if (thd->variables.sync_replication
|
||||
&& trx->repl_wait_binlog_name
|
||||
&& innobase_repl_state != 0) {
|
||||
|
||||
struct timespec abstime;
|
||||
int cmp;
|
||||
int ret;
|
||||
|
||||
/* In synchronous replication, let us wait until the MySQL
|
||||
replication has sent the relevant binlog segment to the
|
||||
replication slave. */
|
||||
|
||||
pthread_mutex_lock(&innobase_repl_cond_mutex);
|
||||
try_again:
|
||||
if (innobase_repl_state == 0) {
|
||||
|
||||
pthread_mutex_unlock(&innobase_repl_cond_mutex);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
cmp = strcmp(innobase_repl_file_name,
|
||||
trx->repl_wait_binlog_name);
|
||||
if (cmp > 0
|
||||
|| (cmp == 0 && innobase_repl_pos
|
||||
>= (my_off_t)trx->repl_wait_binlog_pos)) {
|
||||
/* We have already sent the relevant binlog to the
|
||||
slave: no need to wait here */
|
||||
|
||||
pthread_mutex_unlock(&innobase_repl_cond_mutex);
|
||||
|
||||
/* printf("Binlog now sent\n"); */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Let us update the info about the minimum binlog position
|
||||
of waiting threads in the innobase_repl_... variables */
|
||||
|
||||
if (innobase_repl_wait_file_name_inited != 0) {
|
||||
cmp = strcmp(trx->repl_wait_binlog_name,
|
||||
innobase_repl_wait_file_name);
|
||||
if (cmp < 0
|
||||
|| (cmp == 0 && (my_off_t)trx->repl_wait_binlog_pos
|
||||
<= innobase_repl_wait_pos)) {
|
||||
/* This thd has an even lower position, let
|
||||
us update the minimum info */
|
||||
|
||||
strcpy(innobase_repl_wait_file_name,
|
||||
trx->repl_wait_binlog_name);
|
||||
|
||||
innobase_repl_wait_pos =
|
||||
trx->repl_wait_binlog_pos;
|
||||
}
|
||||
} else {
|
||||
strcpy(innobase_repl_wait_file_name,
|
||||
trx->repl_wait_binlog_name);
|
||||
|
||||
innobase_repl_wait_pos = trx->repl_wait_binlog_pos;
|
||||
|
||||
innobase_repl_wait_file_name_inited = 1;
|
||||
}
|
||||
set_timespec(abstime, thd->variables.sync_replication_timeout);
|
||||
|
||||
/* Let us suspend this thread to wait on the condition;
|
||||
when replication has progressed far enough, we will release
|
||||
these waiting threads. The following call
|
||||
pthread_cond_timedwait also atomically unlocks
|
||||
innobase_repl_cond_mutex. */
|
||||
|
||||
innobase_repl_n_wait_threads++;
|
||||
|
||||
/* printf("Waiting for binlog to be sent\n"); */
|
||||
|
||||
ret = pthread_cond_timedwait(&innobase_repl_cond,
|
||||
&innobase_repl_cond_mutex, &abstime);
|
||||
innobase_repl_n_wait_threads--;
|
||||
|
||||
if (ret != 0) {
|
||||
ut_print_timestamp(stderr);
|
||||
|
||||
sql_print_error("MySQL synchronous replication was "
|
||||
"not able to send the binlog to the "
|
||||
"slave within the timeout %lu. We "
|
||||
"assume that the slave has become "
|
||||
"inaccessible, and switch off "
|
||||
"synchronous replication until the "
|
||||
"communication to the slave works "
|
||||
"again. MySQL synchronous replication "
|
||||
"has sent binlog to the slave up to "
|
||||
"file %s, position %lu. This "
|
||||
"transaction needs it to be sent up "
|
||||
"to file %s, position %lu.",
|
||||
thd->variables.sync_replication_timeout,
|
||||
innobase_repl_file_name,
|
||||
(ulong) innobase_repl_pos,
|
||||
trx->repl_wait_binlog_name,
|
||||
(ulong) trx->repl_wait_binlog_pos);
|
||||
|
||||
innobase_repl_state = 0;
|
||||
|
||||
pthread_mutex_unlock(&innobase_repl_cond_mutex);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
goto try_again;
|
||||
}
|
||||
#endif // HAVE_REPLICATION
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
/*********************************************************************
|
||||
In synchronous replication, reports to InnoDB up to which binlog position
|
||||
we have sent the binlog to the slave. Note that replication is synchronous
|
||||
for one slave only. For other slaves, we do nothing in this function. This
|
||||
function is used in a replication master. */
|
||||
|
||||
int
|
||||
innobase_repl_report_sent_binlog(
|
||||
/*=============================*/
|
||||
/* out: 0 */
|
||||
THD* thd, /* in: thread doing the binlog communication to
|
||||
the slave */
|
||||
char* log_file_name, /* in: binlog file name */
|
||||
my_off_t end_offset) /* in: the offset in the binlog file up to
|
||||
which we sent the contents to the slave */
|
||||
{
|
||||
int cmp;
|
||||
ibool can_release_threads = 0;
|
||||
|
||||
/* If synchronous replication is not switched on, or this thd is
|
||||
sending binlog to a slave where we do not need synchronous replication,
|
||||
then return immediately */
|
||||
|
||||
if (thd->server_id != thd->variables.sync_replication_slave_id) {
|
||||
|
||||
/* Do nothing */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&innobase_repl_cond_mutex);
|
||||
|
||||
if (innobase_repl_state == 0) {
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
sql_print_warning("Switching MySQL synchronous replication on "
|
||||
"again at binlog file %s, position %lu",
|
||||
log_file_name, (ulong) end_offset);
|
||||
|
||||
innobase_repl_state = 1;
|
||||
}
|
||||
|
||||
/* The position should increase monotonically, since just one thread
|
||||
is sending the binlog to the slave for which we want synchronous
|
||||
replication. Let us check this, and print an error to the .err log
|
||||
if that is not the case. */
|
||||
|
||||
if (innobase_repl_file_name_inited) {
|
||||
cmp = strcmp(log_file_name, innobase_repl_file_name);
|
||||
|
||||
if (cmp < 0
|
||||
|| (cmp == 0 && end_offset < innobase_repl_pos)) {
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
sql_print_error("MySQL synchronous replication has "
|
||||
"sent binlog to the slave up to file "
|
||||
"%s, position %lu, but now MySQL "
|
||||
"reports that it sent the binlog only "
|
||||
"up to file %s, position %lu",
|
||||
innobase_repl_file_name,
|
||||
(ulong) innobase_repl_pos,
|
||||
log_file_name, (ulong) end_offset);
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(innobase_repl_file_name, log_file_name);
|
||||
innobase_repl_pos = end_offset;
|
||||
innobase_repl_file_name_inited = 1;
|
||||
|
||||
if (innobase_repl_n_wait_threads > 0) {
|
||||
/* Let us check if some of the waiting threads doing a trx
|
||||
commit can now proceed */
|
||||
|
||||
cmp = strcmp(innobase_repl_file_name,
|
||||
innobase_repl_wait_file_name);
|
||||
if (cmp > 0
|
||||
|| (cmp == 0 && innobase_repl_pos
|
||||
>= innobase_repl_wait_pos)) {
|
||||
|
||||
/* Yes, at least one waiting thread can now proceed:
|
||||
let us release all waiting threads with a broadcast */
|
||||
|
||||
can_release_threads = 1;
|
||||
|
||||
innobase_repl_wait_file_name_inited = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&innobase_repl_cond_mutex);
|
||||
|
||||
if (can_release_threads) {
|
||||
|
||||
pthread_cond_broadcast(&innobase_repl_cond);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
/*********************************************************************
|
||||
Rolls back a transaction or the latest SQL statement. */
|
||||
|
||||
@ -4815,7 +4586,7 @@ ha_innobase::create(
|
||||
possible adaptive hash latch to avoid deadlocks of threads */
|
||||
|
||||
trx_search_latch_release_if_reserved(parent_trx);
|
||||
|
||||
|
||||
trx = trx_allocate_for_mysql();
|
||||
|
||||
trx->mysql_thd = thd;
|
||||
|
@ -303,9 +303,6 @@ int innobase_rollback_by_xid(
|
||||
XID *xid); /* in : X/Open XA Transaction Identification */
|
||||
|
||||
|
||||
int innobase_repl_report_sent_binlog(THD *thd, char *log_file_name,
|
||||
my_off_t end_offset);
|
||||
|
||||
/***********************************************************************
|
||||
Create a consistent view for a cursor based on current transaction
|
||||
which is created if the corresponding MySQL thread still lacks one.
|
||||
|
@ -2684,56 +2684,3 @@ TYPELIB *ha_known_exts(void)
|
||||
}
|
||||
return &known_extensions;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
/*
|
||||
Reports to table handlers up to which position we have sent the binlog
|
||||
to a slave in replication
|
||||
|
||||
SYNOPSIS
|
||||
ha_repl_report_sent_binlog()
|
||||
thd thread doing the binlog communication to the slave
|
||||
log_file_name binlog file name
|
||||
end_offse t the offset in the binlog file up to which we sent the
|
||||
contents to the slave
|
||||
|
||||
NOTES
|
||||
Only works for InnoDB at the moment
|
||||
|
||||
RETURN VALUE
|
||||
Always 0 (= success)
|
||||
*/
|
||||
|
||||
int ha_repl_report_sent_binlog(THD *thd, char *log_file_name,
|
||||
my_off_t end_offset)
|
||||
{
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
return innobase_repl_report_sent_binlog(thd,log_file_name,end_offset);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Reports to table handlers that we stop replication to a specific slave
|
||||
|
||||
SYNOPSIS
|
||||
ha_repl_report_replication_stop()
|
||||
thd thread doing the binlog communication to the slave
|
||||
|
||||
NOTES
|
||||
Does nothing at the moment
|
||||
|
||||
RETURN VALUE
|
||||
Always 0 (= success)
|
||||
|
||||
PARAMETERS
|
||||
*/
|
||||
|
||||
int ha_repl_report_replication_stop(THD *thd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
@ -965,8 +965,3 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht);
|
||||
*/
|
||||
#define trans_need_2pc(thd, all) ((total_ha_2pc > 1) && \
|
||||
!((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
|
||||
|
||||
/* semi-synchronous replication */
|
||||
int ha_repl_report_sent_binlog(THD *thd, char *log_file_name,
|
||||
my_off_t end_offset);
|
||||
int ha_repl_report_replication_stop(THD *thd);
|
||||
|
@ -5899,23 +5899,6 @@ The minimum value for this variable is 4096.",
|
||||
{"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
|
||||
(gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
|
||||
0, 0, 0, 0},
|
||||
#ifdef HAVE_REPLICATION
|
||||
{"sync-replication", OPT_SYNC_REPLICATION,
|
||||
"Enable synchronous replication.",
|
||||
(gptr*) &global_system_variables.sync_replication,
|
||||
(gptr*) &global_system_variables.sync_replication,
|
||||
0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
|
||||
{"sync-replication-slave-id", OPT_SYNC_REPLICATION_SLAVE_ID,
|
||||
"Synchronous replication is wished for this slave.",
|
||||
(gptr*) &global_system_variables.sync_replication_slave_id,
|
||||
(gptr*) &global_system_variables.sync_replication_slave_id,
|
||||
0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
|
||||
{"sync-replication-timeout", OPT_SYNC_REPLICATION_TIMEOUT,
|
||||
"Synchronous replication timeout.",
|
||||
(gptr*) &global_system_variables.sync_replication_timeout,
|
||||
(gptr*) &global_system_variables.sync_replication_timeout,
|
||||
0, GET_ULONG, REQUIRED_ARG, 10, 0, ~0L, 0, 1, 0},
|
||||
#endif /* HAVE_REPLICATION */
|
||||
{"table_cache", OPT_TABLE_CACHE,
|
||||
"The number of open tables for all threads.", (gptr*) &table_cache_size,
|
||||
(gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L,
|
||||
|
@ -376,17 +376,6 @@ sys_var_thd_table_type sys_table_type("table_type",
|
||||
&SV::table_type);
|
||||
sys_var_thd_storage_engine sys_storage_engine("storage_engine",
|
||||
&SV::table_type);
|
||||
#ifdef HAVE_REPLICATION
|
||||
sys_var_sync_binlog_period sys_sync_binlog_period("sync_binlog", &sync_binlog_period);
|
||||
sys_var_thd_ulong sys_sync_replication("sync_replication",
|
||||
&SV::sync_replication);
|
||||
sys_var_thd_ulong sys_sync_replication_slave_id(
|
||||
"sync_replication_slave_id",
|
||||
&SV::sync_replication_slave_id);
|
||||
sys_var_thd_ulong sys_sync_replication_timeout(
|
||||
"sync_replication_timeout",
|
||||
&SV::sync_replication_timeout);
|
||||
#endif
|
||||
sys_var_bool_ptr sys_sync_frm("sync_frm", &opt_sync_frm);
|
||||
sys_var_long_ptr sys_table_cache_size("table_cache",
|
||||
&table_cache_size);
|
||||
@ -708,12 +697,6 @@ sys_var *sys_variables[]=
|
||||
&sys_sql_warnings,
|
||||
&sys_sql_notes,
|
||||
&sys_storage_engine,
|
||||
#ifdef HAVE_REPLICATION
|
||||
&sys_sync_binlog_period,
|
||||
&sys_sync_replication,
|
||||
&sys_sync_replication_slave_id,
|
||||
&sys_sync_replication_timeout,
|
||||
#endif
|
||||
&sys_sync_frm,
|
||||
&sys_table_cache_size,
|
||||
&sys_table_lock_wait_timeout,
|
||||
@ -1009,15 +992,7 @@ struct show_var_st init_vars[]= {
|
||||
{"sql_notes", (char*) &sys_sql_notes, SHOW_BOOL},
|
||||
{"sql_warnings", (char*) &sys_sql_warnings, SHOW_BOOL},
|
||||
{sys_storage_engine.name, (char*) &sys_storage_engine, SHOW_SYS},
|
||||
#ifdef HAVE_REPLICATION
|
||||
{sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS},
|
||||
#endif
|
||||
{sys_sync_frm.name, (char*) &sys_sync_frm, SHOW_SYS},
|
||||
#ifdef HAVE_REPLICATION
|
||||
{sys_sync_replication.name, (char*) &sys_sync_replication, SHOW_SYS},
|
||||
{sys_sync_replication_slave_id.name, (char*) &sys_sync_replication_slave_id,SHOW_SYS},
|
||||
{sys_sync_replication_timeout.name, (char*) &sys_sync_replication_timeout,SHOW_SYS},
|
||||
#endif
|
||||
#ifdef HAVE_TZNAME
|
||||
{"system_time_zone", system_time_zone, SHOW_CHAR},
|
||||
#endif
|
||||
|
@ -552,11 +552,7 @@ struct system_variables
|
||||
my_bool new_mode;
|
||||
my_bool query_cache_wlock_invalidate;
|
||||
my_bool engine_condition_pushdown;
|
||||
#ifdef HAVE_REPLICATION
|
||||
ulong sync_replication;
|
||||
ulong sync_replication_slave_id;
|
||||
ulong sync_replication_timeout;
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
my_bool innodb_table_locks;
|
||||
my_bool innodb_support_xa;
|
||||
|
@ -385,9 +385,6 @@ impossible position";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_sent_binlog(thd, log_file_name, pos);
|
||||
|
||||
/*
|
||||
We need to start a packet with something other than 255
|
||||
to distinguish it from error
|
||||
@ -480,9 +477,6 @@ impossible position";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_sent_binlog(thd, log_file_name, my_b_tell(&log));
|
||||
|
||||
/*
|
||||
No need to save this event. We are only doing simple reads
|
||||
(no real parsing of the events) so we don't need it. And so
|
||||
@ -541,9 +535,6 @@ impossible position";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_sent_binlog(thd, log_file_name, my_b_tell(&log));
|
||||
|
||||
DBUG_PRINT("info", ("log event code %d",
|
||||
(*packet)[LOG_EVENT_OFFSET+1] ));
|
||||
if ((*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
|
||||
@ -657,9 +648,6 @@ impossible position";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_sent_binlog(thd, log_file_name, my_b_tell(&log));
|
||||
|
||||
if ((*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
|
||||
{
|
||||
if (send_file(thd))
|
||||
@ -726,18 +714,12 @@ impossible position";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_sent_binlog(thd, log_file_name, 0);
|
||||
|
||||
packet->length(0);
|
||||
packet->append('\0');
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_replication_stop(thd);
|
||||
|
||||
end_io_cache(&log);
|
||||
(void)my_close(file, MYF(MY_WME));
|
||||
|
||||
@ -749,9 +731,6 @@ end:
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
err:
|
||||
if (thd->variables.sync_replication)
|
||||
ha_repl_report_replication_stop(thd);
|
||||
|
||||
thd->proc_info = "Waiting to finalize termination";
|
||||
end_io_cache(&log);
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user