MXS-1507: Test resultset checksum functionality
The test verifies that different results returned by the replayed transaction cause the replaying to be aborted.
This commit is contained in:
@ -617,6 +617,10 @@ add_test_executable(mxs1506_no_master.cpp mxs1506_no_master mxs1506_delayed_retr
|
|||||||
# https://jira.mariadb.org/browse/MXS-1507
|
# https://jira.mariadb.org/browse/MXS-1507
|
||||||
add_test_executable(mxs1507_trx_replay.cpp mxs1507_trx_replay mxs1507_trx_replay LABELS readwritesplit REPL_BACKEND)
|
add_test_executable(mxs1507_trx_replay.cpp mxs1507_trx_replay mxs1507_trx_replay LABELS readwritesplit REPL_BACKEND)
|
||||||
|
|
||||||
|
# MXS-1507: Inconsistent transactions
|
||||||
|
# https://jira.mariadb.org/browse/MXS-1507
|
||||||
|
add_test_executable(mxs1507_inconsistent_trx.cpp mxs1507_inconsistent_trx mxs1507_trx_replay LABELS readwritesplit REPL_BACKEND)
|
||||||
|
|
||||||
# MXS-1509: Show correct server state for multisource replication
|
# MXS-1509: Show correct server state for multisource replication
|
||||||
# https://jira.mariadb.org/browse/MXS-1509
|
# https://jira.mariadb.org/browse/MXS-1509
|
||||||
add_test_executable(mxs1509.cpp mxs1509 mxs1509 LABELS mysqlmon REPL_BACKEND)
|
add_test_executable(mxs1509.cpp mxs1509 mxs1509 LABELS mysqlmon REPL_BACKEND)
|
||||||
|
63
maxscale-system-test/mxs1507_inconsistent_trx.cpp
Normal file
63
maxscale-system-test/mxs1507_inconsistent_trx.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* MXS-1507: Test inconsistent result detection
|
||||||
|
*
|
||||||
|
* https://jira.mariadb.org/browse/MXS-1507
|
||||||
|
*/
|
||||||
|
#include "testconnections.h"
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
|
||||||
|
auto query = [&](string q)
|
||||||
|
{
|
||||||
|
return execute_query_silent(test.maxscales->conn_rwsplit[0], q.c_str()) == 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ok = [&](string q)
|
||||||
|
{
|
||||||
|
test.assert(query(q), "Query '%s' should work: %s", q.c_str(), mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||||
|
};
|
||||||
|
|
||||||
|
auto err = [&](string q)
|
||||||
|
{
|
||||||
|
test.assert(!query(q), "Query should not work: %s", q.c_str());
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create a table and insert one value
|
||||||
|
test.maxscales->connect();
|
||||||
|
ok("CREATE OR REPLACE TABLE test.t1 (id INT)");
|
||||||
|
ok("INSERT INTO test.t1 VALUES (1)");
|
||||||
|
|
||||||
|
// Make sure it's replicated to all slaves before starting the transaction
|
||||||
|
test.repl->connect();
|
||||||
|
test.repl->sync_slaves();
|
||||||
|
|
||||||
|
// Read the inserted value inside a read-only transaction
|
||||||
|
ok("START TRANSACTION READ ONLY");
|
||||||
|
ok("SELECT * FROM test.t1");
|
||||||
|
|
||||||
|
// Modify the related data mid-transaction
|
||||||
|
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (2)");
|
||||||
|
test.repl->sync_slaves();
|
||||||
|
test.repl->disconnect();
|
||||||
|
|
||||||
|
// Block the node where the transaction is active
|
||||||
|
test.repl->block_node(1);
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
// The checksums for the results should conflict causing the replay to fail
|
||||||
|
err("COMMIT");
|
||||||
|
test.maxscales->disconnect();
|
||||||
|
|
||||||
|
test.maxscales->connect();
|
||||||
|
ok("DROP TABLE test.t1");
|
||||||
|
test.maxscales->disconnect();
|
||||||
|
|
||||||
|
return test.global_result;
|
||||||
|
}
|
Reference in New Issue
Block a user