Commit 21bc3e3f authored by sjaakola's avatar sjaakola Committed by Nirbhay Choubey

refs #2 - added binlog stmt cache reset after commit. This is needed for non-InnoDB statements

parent 9fdae3eb
......@@ -1712,15 +1712,36 @@ int binlog_init(void *p)
return 0;
}
#ifdef WITH_WSREP
#include "wsrep_binlog.h"
#endif /* WITH_WSREP */
static int binlog_close_connection(handlerton *hton, THD *thd)
{
DBUG_ENTER("binlog_close_connection");
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
#ifdef WITH_WSREP
if (cache_mngr && !cache_mngr->trx_cache.empty()) {
IO_CACHE* cache= get_trans_log(thd);
uchar *buf;
size_t len=0;
wsrep_write_cache_buf(cache, &buf, &len);
WSREP_WARN("binlog trx cache not empty (%lu bytes) @ connection close %lu",
len, thd->thread_id);
if (len > 0) wsrep_dump_rbr_buf(thd, buf, len);
cache = cache_mngr->get_binlog_cache_log(false);
wsrep_write_cache_buf(cache, &buf, &len);
WSREP_WARN("binlog stmt cache not empty (%lu bytes) @ connection close %lu",
len, thd->thread_id);
if (len > 0) wsrep_dump_rbr_buf(thd, buf, len);
}
#endif /* WITH_WSREP */
DBUG_ASSERT(cache_mngr->trx_cache.empty() && cache_mngr->stmt_cache.empty());
thd_set_ha_data(thd, binlog_hton, NULL);
cache_mngr->~binlog_cache_mngr();
my_free(cache_mngr);
return 0;
DBUG_RETURN(0);
}
/*
......
......@@ -98,17 +98,32 @@ void wsrep_register_hton(THD* thd, bool all)
*/
void wsrep_post_commit(THD* thd, bool all)
{
if (thd->wsrep_exec_mode == LOCAL_COMMIT)
switch (thd->wsrep_exec_mode)
{
DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED);
if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle))
case LOCAL_COMMIT:
{
DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED);
if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle))
{
DBUG_PRINT("wsrep", ("set committed fail"));
WSREP_WARN("set committed fail: %llu %d",
(long long)thd->real_id, thd->get_stmt_da()->status());
}
wsrep_cleanup_transaction(thd);
break;
}
wsrep_cleanup_transaction(thd);
case LOCAL_STATE:
{
/*
Non-InnoDB statements may have populated events in stmt cache => cleanup
*/
WSREP_DEBUG("cleanup transaction for LOCAL_STATE: %s", thd->query());
wsrep_cleanup_transaction(thd);
break;
}
default: break;
}
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment