This is a partial cherry-pick of 9f11fdd2c122c9b30548c7ab55df8dda643ec659. Use larger BLOB type for mxs812_1, the inserted value exceeds the normal BLOB size. Add a baseline check into bulk_insert to verify that direct connections work (at the moment they don't, needs an investigation). Modified avro_alter to prevent data type conversion errors.
		
			
				
	
	
		
			83 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/**
 | 
						|
 * @file mxs812_1.cpp - Checks "Current no. of conns" maxadmin output after long blob inserting
 | 
						|
 * - set global max_allowed_packet=10000000
 | 
						|
 * - pretare statement INSERT INTO long_blob_table(x, b) VALUES(1, ?)
 | 
						|
 * - load chunks
 | 
						|
 * - execute statement
 | 
						|
 * - wait 5 seconds
 | 
						|
 * - check "Current no. of conns" maxadmin output, expect 0
 | 
						|
 * - repeat test 10 times
 | 
						|
 */
 | 
						|
 | 
						|
 | 
						|
#include "testconnections.h"
 | 
						|
 | 
						|
void run_test(TestConnections *Test, size_t size, int chunks)
 | 
						|
{
 | 
						|
    char *insert_stmt = (char *) "INSERT INTO long_blob_table(x, b) VALUES(1, ?)";
 | 
						|
    MYSQL *conn = Test->conn_rwsplit;
 | 
						|
    MYSQL_STMT * stmt = mysql_stmt_init(conn);
 | 
						|
 | 
						|
    Test->tprintf("Preparing statement");
 | 
						|
    Test->add_result(mysql_stmt_prepare(stmt, insert_stmt, strlen(insert_stmt)), "Error preparing stmt: %s\n",
 | 
						|
                     mysql_stmt_error(stmt));
 | 
						|
 | 
						|
    MYSQL_BIND param[1];
 | 
						|
    param[0].buffer_type = MYSQL_TYPE_STRING;
 | 
						|
    param[0].is_null = 0;
 | 
						|
 | 
						|
    Test->add_result(mysql_stmt_bind_param(stmt, param), "Error parameter binding: %s\n", mysql_stmt_error(stmt));
 | 
						|
 | 
						|
    unsigned long *data = (unsigned long *) malloc(size * sizeof(long int));
 | 
						|
 | 
						|
    memset(data, '.', size * sizeof(long int));
 | 
						|
 | 
						|
    Test->tprintf("Sending %d x %d bytes of data", size, chunks);
 | 
						|
    for (int i = 0; i < chunks; i++)
 | 
						|
    {
 | 
						|
        Test->set_timeout(600);
 | 
						|
        Test->tprintf("Chunk #%d\n", i);
 | 
						|
        if (mysql_stmt_send_long_data(stmt, 0, (char *) data, size * sizeof(long int)) != 0)
 | 
						|
        {
 | 
						|
            Test->add_result(1, "Error inserting data, iteration %d, error %s\n", i, mysql_stmt_error(stmt));
 | 
						|
            return;
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    Test->set_timeout(600);
 | 
						|
    Test->tprintf("Executing statement");
 | 
						|
    Test->add_result(mysql_stmt_execute(stmt), "INSERT Statement with BLOB failed, error is %s\n",
 | 
						|
                     mysql_stmt_error(stmt));
 | 
						|
 | 
						|
    Test->stop_timeout();
 | 
						|
    sleep(5);
 | 
						|
    Test->check_current_operations(0);
 | 
						|
    Test->tprintf("Closing statement");
 | 
						|
    Test->add_result(mysql_stmt_close(stmt), "Error closing stmt\n");
 | 
						|
}
 | 
						|
 | 
						|
int main(int argc, char *argv[])
 | 
						|
{
 | 
						|
    TestConnections * Test = new TestConnections(argc, argv);
 | 
						|
    Test->set_timeout(300);
 | 
						|
    int iter = 10;
 | 
						|
 | 
						|
    Test->repl->execute_query_all_nodes( (char *) "set global max_allowed_packet=10000000");
 | 
						|
 | 
						|
    /** Create test table */
 | 
						|
    Test->repl->connect();
 | 
						|
    Test->try_query(Test->repl->nodes[0], (char*)"DROP TABLE IF EXISTS long_blob_table");
 | 
						|
    Test->try_query(Test->repl->nodes[0], (char*)"CREATE TABLE long_blob_table(x INT, b LONGBLOB)");
 | 
						|
 | 
						|
    Test->connect_maxscale();
 | 
						|
    Test->tprintf("Starting test");
 | 
						|
    for (int i = 0; i < iter; i++)
 | 
						|
    {
 | 
						|
        run_test(Test, 500000, 10);
 | 
						|
    }
 | 
						|
 | 
						|
    int rval = Test->global_result;
 | 
						|
    delete Test;
 | 
						|
    return rval;
 | 
						|
}
 |