Skip to content

Commit 692c764

Browse files
committed
BUG#36252805 Non existent binlog cache means empty
Problem: Checking if binlog cache is empty requires creating it first, then it will be empty. This causes sessions which never had or should not have binlog cache to get one, thus consuming unnecessary resources indefinitely. Analysis: It can be seen that binlog cache is created during for example rollback although the binlog cache does not exists and thus have no content. Several other places consider non existent binlog cache as empty. Solution: Change THD::is_binlog_cache_empty() to return true when binlog cache does not exist and remove calls to create the binlog cache before calling that function. Change-Id: I87e43dcff33a46790d0d29bc8259e38a1d1bd0ed
1 parent 8103422 commit 692c764

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

sql/binlog.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9428,13 +9428,14 @@ bool THD::is_binlog_cache_empty(bool is_transactional) const {
94289428
// If opt_bin_log==0, it is not safe to call thd_get_cache_mngr
94299429
// because binlog_hton has not been completely set up.
94309430
assert(opt_bin_log);
9431-
binlog_cache_mngr *cache_mngr = thd_get_cache_mngr(this);
94329431

9433-
// cache_mngr is NULL until we call thd->binlog_setup_trx_data, so
9434-
// we assert that this has been done.
9435-
assert(cache_mngr != nullptr);
9432+
binlog_cache_mngr *const cache_mngr = thd_get_cache_mngr(this);
9433+
if (cache_mngr == nullptr) {
9434+
// The cache has not been setup and is thus empty
9435+
return true;
9436+
}
94369437

9437-
binlog_cache_data *cache_data =
9438+
binlog_cache_data *const cache_data =
94389439
cache_mngr->get_binlog_cache_data(is_transactional);
94399440
assert(cache_data != nullptr);
94409441

sql/rpl_gtid_state.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,6 @@ void Gtid_state::update_gtids_impl_own_anonymous(THD *thd, bool *more_trx) {
925925
See comment for the update_gtids_impl_begin function.
926926
*/
927927
if (opt_bin_log) {
928-
// Needed before is_binlog_cache_empty.
929-
thd->binlog_setup_trx_data();
930928
if (!thd->is_binlog_cache_empty(true)) {
931929
*more_trx = true;
932930
DBUG_PRINT("info", ("Transaction cache is non-empty: setting "

0 commit comments

Comments
 (0)