mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-7194: galera fails to replicate DDL queries when using binlog_checksum
Restore fix for MDEV-4328 (revno: 3391) that got accidentally overwritten while merging : http://bazaar.launchpad.net/~codership/codership-mysql/5.5-23/revision/3900 Added a test case.
This commit is contained in:
36
mysql-test/suite/galera/r/binlog_checksum.result
Normal file
36
mysql-test/suite/galera/r/binlog_checksum.result
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# On node_1
|
||||||
|
SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM;
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM=CRC32;
|
||||||
|
# On node_2
|
||||||
|
SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM;
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM=CRC32;
|
||||||
|
USE test;
|
||||||
|
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=INNODB;
|
||||||
|
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
c1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
SELECT * FROM test.t1;
|
||||||
|
c1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
|
||||||
|
# On node_2
|
||||||
|
SELECT * FROM test.t1;
|
||||||
|
c1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved;
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved;
|
||||||
|
# End of test
|
36
mysql-test/suite/galera/t/binlog_checksum.test
Normal file
36
mysql-test/suite/galera/t/binlog_checksum.test
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
--source include/galera_cluster.inc
|
||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
--echo # On node_1
|
||||||
|
--connection node_1
|
||||||
|
SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM;
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM=CRC32;
|
||||||
|
|
||||||
|
--echo # On node_2
|
||||||
|
--connection node_2
|
||||||
|
SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM;
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM=CRC32;
|
||||||
|
|
||||||
|
USE test;
|
||||||
|
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=INNODB;
|
||||||
|
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
SELECT * FROM test.t1;
|
||||||
|
|
||||||
|
--echo
|
||||||
|
--echo # On node_2
|
||||||
|
--connection node_2
|
||||||
|
SELECT * FROM test.t1;
|
||||||
|
|
||||||
|
--let $galera_diff_statement = SELECT * FROM t1
|
||||||
|
--source include/galera_diff.inc
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
DROP TABLE t1;
|
||||||
|
--connection node_1
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved;
|
||||||
|
--connection node_2
|
||||||
|
SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved;
|
||||||
|
|
||||||
|
--source include/galera_end.inc
|
||||||
|
--echo # End of test
|
@ -1000,6 +1000,7 @@ THD::THD()
|
|||||||
wsrep_applier(is_applier),
|
wsrep_applier(is_applier),
|
||||||
wsrep_applier_closing(FALSE),
|
wsrep_applier_closing(FALSE),
|
||||||
wsrep_client_thread(0),
|
wsrep_client_thread(0),
|
||||||
|
wsrep_apply_format(0),
|
||||||
wsrep_apply_toi(false),
|
wsrep_apply_toi(false),
|
||||||
#endif
|
#endif
|
||||||
m_parser_state(NULL),
|
m_parser_state(NULL),
|
||||||
|
@ -2389,6 +2389,7 @@ public:
|
|||||||
const char* wsrep_TOI_pre_query; /* a query to apply before
|
const char* wsrep_TOI_pre_query; /* a query to apply before
|
||||||
the actual TOI query */
|
the actual TOI query */
|
||||||
size_t wsrep_TOI_pre_query_len;
|
size_t wsrep_TOI_pre_query_len;
|
||||||
|
void* wsrep_apply_format;
|
||||||
bool wsrep_apply_toi; /* applier processing in TOI */
|
bool wsrep_apply_toi; /* applier processing in TOI */
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "wsrep_binlog.h" // wsrep_dump_rbr_buf()
|
#include "wsrep_binlog.h" // wsrep_dump_rbr_buf()
|
||||||
|
|
||||||
#include "log_event.h" // EVENT_LEN_OFFSET, etc.
|
#include "log_event.h" // EVENT_LEN_OFFSET, etc.
|
||||||
|
|
||||||
#include "wsrep_applier.h"
|
#include "wsrep_applier.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -64,7 +63,25 @@ err:
|
|||||||
#include "rpl_rli.h" // class Relay_log_info;
|
#include "rpl_rli.h" // class Relay_log_info;
|
||||||
#include "sql_base.h" // close_temporary_table()
|
#include "sql_base.h" // close_temporary_table()
|
||||||
|
|
||||||
extern const Format_description_log_event *wsrep_format_desc;
|
static inline void
|
||||||
|
wsrep_set_apply_format(THD* thd, Format_description_log_event* ev)
|
||||||
|
{
|
||||||
|
if (thd->wsrep_apply_format)
|
||||||
|
{
|
||||||
|
delete (Format_description_log_event*)thd->wsrep_apply_format;
|
||||||
|
}
|
||||||
|
thd->wsrep_apply_format= ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Format_description_log_event*
|
||||||
|
wsrep_get_apply_format(THD* thd)
|
||||||
|
{
|
||||||
|
if (thd->wsrep_apply_format)
|
||||||
|
{
|
||||||
|
return (Format_description_log_event*) thd->wsrep_apply_format;
|
||||||
|
}
|
||||||
|
return thd->wsrep_rli->relay_log.description_event_for_exec;
|
||||||
|
}
|
||||||
|
|
||||||
static wsrep_cb_status_t wsrep_apply_events(THD* thd,
|
static wsrep_cb_status_t wsrep_apply_events(THD* thd,
|
||||||
const void* events_buf,
|
const void* events_buf,
|
||||||
@ -98,7 +115,8 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd,
|
|||||||
{
|
{
|
||||||
int exec_res;
|
int exec_res;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
Log_event* ev= wsrep_read_log_event(&buf, &buf_len, wsrep_format_desc);
|
Log_event* ev= wsrep_read_log_event(&buf, &buf_len,
|
||||||
|
wsrep_get_apply_format(thd));
|
||||||
|
|
||||||
if (!ev)
|
if (!ev)
|
||||||
{
|
{
|
||||||
@ -111,6 +129,9 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd,
|
|||||||
typ= ev->get_type_code();
|
typ= ev->get_type_code();
|
||||||
|
|
||||||
switch (typ) {
|
switch (typ) {
|
||||||
|
case FORMAT_DESCRIPTION_EVENT:
|
||||||
|
wsrep_set_apply_format(thd, (Format_description_log_event*)ev);
|
||||||
|
continue;
|
||||||
case WRITE_ROWS_EVENT:
|
case WRITE_ROWS_EVENT:
|
||||||
case UPDATE_ROWS_EVENT:
|
case UPDATE_ROWS_EVENT:
|
||||||
case DELETE_ROWS_EVENT:
|
case DELETE_ROWS_EVENT:
|
||||||
@ -339,6 +360,7 @@ wsrep_cb_status_t wsrep_commit_cb(void* const ctx,
|
|||||||
else
|
else
|
||||||
rcode = wsrep_rollback(thd, meta->gtid.seqno);
|
rcode = wsrep_rollback(thd, meta->gtid.seqno);
|
||||||
|
|
||||||
|
wsrep_set_apply_format(thd, NULL);
|
||||||
thd->mdl_context.release_transactional_locks();
|
thd->mdl_context.release_transactional_locks();
|
||||||
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
|
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
|
||||||
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
|
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "log_event.h"
|
#include "log_event.h"
|
||||||
#include <slave.h>
|
#include <slave.h>
|
||||||
|
|
||||||
Format_description_log_event *wsrep_format_desc = NULL;
|
|
||||||
wsrep_t *wsrep = NULL;
|
wsrep_t *wsrep = NULL;
|
||||||
my_bool wsrep_emulate_bin_log = FALSE; // activating parts of binlog interface
|
my_bool wsrep_emulate_bin_log = FALSE; // activating parts of binlog interface
|
||||||
|
|
||||||
@ -498,7 +497,6 @@ int wsrep_init()
|
|||||||
|
|
||||||
wsrep_ready_set(FALSE);
|
wsrep_ready_set(FALSE);
|
||||||
assert(wsrep_provider);
|
assert(wsrep_provider);
|
||||||
wsrep_format_desc= new Format_description_log_event(4);
|
|
||||||
wsrep_init_position();
|
wsrep_init_position();
|
||||||
|
|
||||||
if ((rcode= wsrep_load(wsrep_provider, &wsrep, wsrep_log_cb)) != WSREP_OK)
|
if ((rcode= wsrep_load(wsrep_provider, &wsrep, wsrep_log_cb)) != WSREP_OK)
|
||||||
@ -718,8 +716,6 @@ void wsrep_deinit(bool free_options)
|
|||||||
provider_version[0]= '\0';
|
provider_version[0]= '\0';
|
||||||
provider_vendor[0]= '\0';
|
provider_vendor[0]= '\0';
|
||||||
|
|
||||||
delete wsrep_format_desc;
|
|
||||||
wsrep_format_desc= NULL;
|
|
||||||
wsrep_inited= 0;
|
wsrep_inited= 0;
|
||||||
|
|
||||||
if (free_options)
|
if (free_options)
|
||||||
@ -1133,6 +1129,12 @@ int wsrep_to_buf_helper(
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
int ret(0);
|
int ret(0);
|
||||||
|
|
||||||
|
Format_description_log_event *tmp_fd= new Format_description_log_event(4);
|
||||||
|
tmp_fd->checksum_alg= binlog_checksum_options;
|
||||||
|
tmp_fd->write(&tmp_io_cache);
|
||||||
|
delete tmp_fd;
|
||||||
|
|
||||||
/* if there is prepare query, add event for it */
|
/* if there is prepare query, add event for it */
|
||||||
if (thd->wsrep_TOI_pre_query)
|
if (thd->wsrep_TOI_pre_query)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user