 ed44c45be1
			
		
	
	ed44c45be1
	
	
	
		
			
			When a backend is waiting for a response but no statement is stored for the session, the buffer where the stored statement is copied is not modified. This means that it needs to be initialized to a NULL value. Added a test that checks that the behavior works as expected even with persistent connections. A second test reproduces the crash by executing parallel SET commands while slaves are blocked. There is still a behavioral problem in readwritesplit. If a session command is being executed and it fails on a slave, an error is sent to the client. In this case it would not be necessary to close the session if the master is still alive.
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /**
 | |
|  * Test for MXS-1323.
 | |
|  * - Check that retried reads work with persistent connections
 | |
|  */
 | |
| 
 | |
| #include "testconnections.h"
 | |
| 
 | |
| void* async_block(void* data)
 | |
| {
 | |
|     TestConnections *test = (TestConnections*)data;
 | |
|     sleep(5);
 | |
|     test->tprintf("Blocking slave");
 | |
|     test->repl->block_node(1);
 | |
|     return NULL;
 | |
| }
 | |
| 
 | |
| std::string do_query(TestConnections& test)
 | |
| {
 | |
|     MYSQL* conn = test.open_rwsplit_connection();
 | |
| 
 | |
|     const char* query = "SELECT SLEEP(10), @@server_id";
 | |
|     char output[512] = "";
 | |
| 
 | |
|     find_field(conn, query, "@@server_id", output);
 | |
|     mysql_close(conn);
 | |
| 
 | |
|     return std::string(output);
 | |
| }
 | |
| 
 | |
| int main(int argc, char *argv[])
 | |
| {
 | |
|     TestConnections test(argc, argv);
 | |
| 
 | |
|     char server_id[2][1024];
 | |
|     test.repl->connect();
 | |
|     std::string master = test.repl->get_server_id_str(0);
 | |
|     std::string slave = test.repl->get_server_id_str(1);
 | |
|     test.repl->close_connections();
 | |
| 
 | |
|     test.set_timeout(60);
 | |
|     test.add_result(do_query(test) != slave, "The slave should respond to the first query");
 | |
| 
 | |
|     pthread_t thr;
 | |
|     pthread_create(&thr, NULL, async_block, &test);
 | |
|     test.add_result(do_query(test) != master, "The master should respond to the second query");
 | |
|     pthread_join(thr, NULL);
 | |
|     test.repl->unblock_node(1);
 | |
| 
 | |
|     return test.global_result;
 | |
| }
 |