From 234c2eb740740cacc0e4df7cf9e5f4c2d492f3da Mon Sep 17 00:00:00 2001 From: Gagan Goel Date: Wed, 16 Sep 2020 16:13:29 -0400 Subject: [PATCH] MCOL-4285 In replication, perform LDI on the slave directly into the columnstore table, and not into the cache. LDI performed on a master, comes in as a SQLCOM_END sql_command on the slave, when binlog_format != STATEMENT. If the cache already had some records, we were earlier flushing the cache for the LDI on the slave. This patch detects whether we are in the slave thread or not, if so, then we don't do a cache flush if sql_command = SQLCOM_END. --- dbcon/mysql/ha_mcs.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbcon/mysql/ha_mcs.cpp b/dbcon/mysql/ha_mcs.cpp index 8ddc4abeb..7f8f51b40 100644 --- a/dbcon/mysql/ha_mcs.cpp +++ b/dbcon/mysql/ha_mcs.cpp @@ -1204,8 +1204,13 @@ my_bool get_status_and_flush_cache(void *param, if (!cache->lock_counter++) { ha_rows num_rows = cache->num_rows_cached(); - if ((!cache->insert_command && num_rows != 0) || - num_rows >= get_cache_flush_threshold(current_thd)) + if (((!cache->insert_command && num_rows != 0) || + num_rows >= get_cache_flush_threshold(current_thd)) && + // In replication, LDI on a master comes as sql_command = SQLCOM_END + // on the slave, if binlog_format != STATEMENT. See mysql_load + // function in sql/sql_load.cc to know why. If this is the case, + // make sure we don't flush the cache. + (!current_thd->slave_thread || sql_command != SQLCOM_END)) { if ((error= cache->flush_insert_cache())) { @@ -1740,7 +1745,7 @@ void ha_mcs_cache::start_bulk_insert(ha_rows rows, uint flags) bzero(&cache_handler->copy_info, sizeof(cache_handler->copy_info)); return cache_handler->start_bulk_insert(rows, flags); } - return parent::start_bulk_insert_from_cache(rows, flags); + return parent::start_bulk_insert(rows, flags); } else {