mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
First part of fix for BUG#7998 "Replication should be more clever about when to replicate RELEASE_LOCK()"
(next part is updating test results)
This commit is contained in:
parent
c6cedf52e3
commit
c4ac232d17
4 changed files with 18 additions and 29 deletions
|
@ -2857,18 +2857,6 @@ void item_user_lock_free(void)
|
|||
void item_user_lock_release(User_level_lock *ull)
|
||||
{
|
||||
ull->locked=0;
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
char buf[256];
|
||||
const char *command="DO RELEASE_LOCK(\"";
|
||||
String tmp(buf,sizeof(buf), system_charset_info);
|
||||
tmp.copy(command, strlen(command), tmp.charset());
|
||||
tmp.append(ull->key,ull->key_length);
|
||||
tmp.append("\")", 2);
|
||||
Query_log_event qev(current_thd, tmp.ptr(), tmp.length(), 0, FALSE);
|
||||
qev.error_code=0; // this query is always safe to run on slave
|
||||
mysql_bin_log.write(&qev);
|
||||
}
|
||||
if (--ull->count)
|
||||
pthread_cond_signal(&ull->cond);
|
||||
else
|
||||
|
@ -2992,6 +2980,16 @@ longlong Item_func_get_lock::val_int()
|
|||
User_level_lock *ull;
|
||||
int error=0;
|
||||
|
||||
/*
|
||||
In slave thread no need to get locks, everything is serialized. Anyway
|
||||
there is no way to make GET_LOCK() work on slave like it did on master
|
||||
(i.e. make it return exactly the same value) because we don't have the
|
||||
same other concurrent threads environment. No matter what we return here,
|
||||
it's not guaranteed to be same as on master.
|
||||
*/
|
||||
if (thd->slave_thread)
|
||||
return 1;
|
||||
|
||||
pthread_mutex_lock(&LOCK_user_locks);
|
||||
|
||||
if (!res || !res->length())
|
||||
|
|
|
@ -1616,9 +1616,9 @@ end:
|
|||
probably, so data_buf will be freed, so the thd->... listed above will be
|
||||
pointers to freed memory.
|
||||
So we must set them to 0, so that those bad pointers values are not later
|
||||
used. Note that "cleanup" queries (automatic DO RELEASE_LOCK() and DROP
|
||||
TEMPORARY TABLE don't suffer from these assignments to 0 as DROP TEMPORARY
|
||||
TABLE uses the db.table syntax).
|
||||
used. Note that "cleanup" queries like automatic DROP TEMPORARY TABLE
|
||||
don't suffer from these assignments to 0 as DROP TEMPORARY
|
||||
TABLE uses the db.table syntax.
|
||||
*/
|
||||
thd->db= thd->catalog= 0; // prevent db from being freed
|
||||
thd->query= 0; // just to be sure
|
||||
|
@ -3663,8 +3663,8 @@ void Stop_log_event::print(FILE* file, bool short_form, LAST_EVENT_INFO* last_ev
|
|||
|
||||
The master stopped.
|
||||
We used to clean up all temporary tables but this is useless as, as the
|
||||
master has shut down properly, it has written all DROP TEMPORARY TABLE and DO
|
||||
RELEASE_LOCK (prepared statements' deletion is TODO).
|
||||
master has shut down properly, it has written all DROP TEMPORARY TABLE
|
||||
(prepared statements' deletion is TODO only when we binlog prep stmts).
|
||||
We used to clean up slave_load_tmpdir, but this is useless as it has been
|
||||
cleared at the end of LOAD DATA INFILE.
|
||||
So we have nothing to do here.
|
||||
|
|
|
@ -5799,7 +5799,7 @@ static void mysql_init_variables(void)
|
|||
opt_log= opt_update_log= opt_bin_log= opt_slow_log= 0;
|
||||
opt_disable_networking= opt_skip_show_db=0;
|
||||
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
|
||||
opt_tc_log_file= "tc.log"; // no hostname in tc_log file name !
|
||||
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
|
||||
opt_secure_auth= 0;
|
||||
opt_bootstrap= opt_myisam_log= 0;
|
||||
mqh_used= 0;
|
||||
|
|
13
sql/slave.cc
13
sql/slave.cc
|
@ -3257,7 +3257,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
|
|||
else if (init_relay_log_pos(rli,
|
||||
rli->group_relay_log_name,
|
||||
rli->group_relay_log_pos,
|
||||
1, &errmsg))
|
||||
1, &errmsg, 1))
|
||||
sql_print_error("Error initializing relay log position: %s",
|
||||
errmsg);
|
||||
else
|
||||
|
@ -3273,16 +3273,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
|
|||
slave_trans_retries);
|
||||
}
|
||||
if (!((thd->options & OPTION_BEGIN) && opt_using_transactions))
|
||||
{
|
||||
rli->trans_retries= slave_trans_retries; // restart from fresh
|
||||
/*
|
||||
TODO: when merged into 5.0, when slave does auto-rollback if
|
||||
corrupted binlog, this should reset the retry counter too
|
||||
(any rollback should). In fact it will work, as here we are just out
|
||||
of a Format_description_log_event::exec_event() which rolled back.
|
||||
But check repl code in 5.0 for new ha_rollback calls, just in case.
|
||||
*/
|
||||
}
|
||||
}
|
||||
return exec_res;
|
||||
}
|
||||
|
@ -4245,7 +4236,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len)
|
|||
master server shutdown. The only thing this does is cleaning. But
|
||||
cleaning is already done on a per-master-thread basis (as the master
|
||||
server is shutting down cleanly, it has written all DROP TEMPORARY TABLE
|
||||
and DO RELEASE_LOCK; prepared statements' deletion are TODO).
|
||||
prepared statements' deletion are TODO only when we binlog prep stmts).
|
||||
|
||||
We don't even increment mi->master_log_pos, because we may be just after
|
||||
a Rotate event. Btw, in a few milliseconds we are going to have a Start
|
||||
|
|
Loading…
Reference in a new issue