mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-7871 Tests fail massively on "Assertion `status_var.memory_used == 0'" when run with --ps --embedded.
As the MF_THREAD_SPECIFIC was introduced to the alloc_root's and the prealloc added to the statement::mem_root and statement::result.alloc, we have to adjust the embedded server to it. The preallocation was removed for the embedded server as it makes no sence for it. The msyqltest should free the statement inside the proper thead to make the memory statistics happy.
This commit is contained in:
parent
a117030377
commit
02421aa284
2 changed files with 35 additions and 8 deletions
|
@ -839,6 +839,7 @@ static void handle_no_active_connection(struct st_command* command,
|
|||
#define EMB_END_CONNECTION 3
|
||||
#define EMB_PREPARE_STMT 4
|
||||
#define EMB_EXECUTE_STMT 5
|
||||
#define EMB_CLOSE_STMT 6
|
||||
|
||||
/* workaround for MySQL BUG#57491 */
|
||||
#undef MY_WME
|
||||
|
@ -887,6 +888,9 @@ pthread_handler_t connection_thread(void *arg)
|
|||
case EMB_EXECUTE_STMT:
|
||||
cn->result= mysql_stmt_execute(cn->stmt);
|
||||
break;
|
||||
case EMB_CLOSE_STMT:
|
||||
cn->result= mysql_stmt_close(cn->stmt);
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
|
@ -984,6 +988,17 @@ static int do_stmt_execute(struct st_connection *cn)
|
|||
}
|
||||
|
||||
|
||||
static int do_stmt_close(struct st_connection *cn)
|
||||
{
|
||||
/* The cn->stmt is already set. */
|
||||
if (!cn->has_thread)
|
||||
return mysql_stmt_close(cn->stmt);
|
||||
signal_connection_thd(cn, EMB_CLOSE_STMT);
|
||||
wait_query_thread_done(cn);
|
||||
return cn->result;
|
||||
}
|
||||
|
||||
|
||||
static void emb_close_connection(struct st_connection *cn)
|
||||
{
|
||||
if (!cn->has_thread)
|
||||
|
@ -1019,6 +1034,7 @@ static void init_connection_thd(struct st_connection *cn)
|
|||
#define do_read_query_result(cn) mysql_read_query_result(cn->mysql)
|
||||
#define do_stmt_prepare(cn, q, q_len) mysql_stmt_prepare(cn->stmt, q, q_len)
|
||||
#define do_stmt_execute(cn) mysql_stmt_execute(cn->stmt)
|
||||
#define do_stmt_close(cn) mysql_stmt_close(cn->stmt)
|
||||
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
@ -1378,11 +1394,11 @@ void close_connections()
|
|||
DBUG_ENTER("close_connections");
|
||||
for (--next_con; next_con >= connections; --next_con)
|
||||
{
|
||||
if (next_con->stmt)
|
||||
do_stmt_close(next_con);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
emb_close_connection(next_con);
|
||||
#endif
|
||||
if (next_con->stmt)
|
||||
mysql_stmt_close(next_con->stmt);
|
||||
next_con->stmt= 0;
|
||||
mysql_close(next_con->mysql);
|
||||
next_con->mysql= 0;
|
||||
|
@ -5635,7 +5651,11 @@ void do_close_connection(struct st_command *command)
|
|||
con->mysql->net.vio = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#endif /*!EMBEDDED_LIBRARY*/
|
||||
if (con->stmt)
|
||||
do_stmt_close(con);
|
||||
con->stmt= 0;
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
/*
|
||||
As query could be still executed in a separate theread
|
||||
we need to check if the query's thread was finished and probably wait
|
||||
|
@ -5643,9 +5663,6 @@ void do_close_connection(struct st_command *command)
|
|||
*/
|
||||
emb_close_connection(con);
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
if (con->stmt)
|
||||
mysql_stmt_close(con->stmt);
|
||||
con->stmt= 0;
|
||||
|
||||
mysql_close(con->mysql);
|
||||
con->mysql= 0;
|
||||
|
|
|
@ -1508,6 +1508,12 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
|||
memory
|
||||
*/
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define STMT_INIT_PREALLOC(S) 0
|
||||
#else
|
||||
#define STMT_INIT_PREALLOC(S) S
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
MYSQL_STMT * STDCALL
|
||||
mysql_stmt_init(MYSQL *mysql)
|
||||
{
|
||||
|
@ -1526,8 +1532,10 @@ mysql_stmt_init(MYSQL *mysql)
|
|||
DBUG_RETURN(NULL);
|
||||
}
|
||||
|
||||
init_alloc_root(&stmt->mem_root, 2048, 2048, MYF(MY_THREAD_SPECIFIC));
|
||||
init_alloc_root(&stmt->result.alloc, 4096, 4096, MYF(MY_THREAD_SPECIFIC));
|
||||
init_alloc_root(&stmt->mem_root, 2048, STMT_INIT_PREALLOC(2048),
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
init_alloc_root(&stmt->result.alloc, 4096, STMT_INIT_PREALLOC(4096),
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
stmt->result.alloc.min_malloc= sizeof(MYSQL_ROWS);
|
||||
mysql->stmts= list_add(mysql->stmts, &stmt->list);
|
||||
stmt->list.data= stmt;
|
||||
|
@ -1544,6 +1552,8 @@ mysql_stmt_init(MYSQL *mysql)
|
|||
DBUG_RETURN(stmt);
|
||||
}
|
||||
|
||||
#undef STMT_INIT_PREALLOC
|
||||
|
||||
|
||||
/*
|
||||
Prepare server side statement with query.
|
||||
|
|
Loading…
Reference in a new issue