Skip to content

Commit

Permalink
[bugfix] Issue: #64 replication regression with RBR and partition tables
Browse files Browse the repository at this point in the history
This patch is ported from MySQL upstream (commit id: 9414c7).

Bug#25687813 REPLICATION REGRESSION WITH RBR AND PARTITIONED TABLES

PROBLEM
-------

While applying update the slave is trying to initialize all partitions
before reading from rnd_pos() call. This is done for each row update
because of which the performance is getting effected.

FIX
---

Initialize only the partition on which rnd_pos() is called.
  • Loading branch information
AliSQL authored and AliSQL committed May 1, 2018
1 parent 4ec960a commit aa61f56
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 1 addition & 4 deletions sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4981,14 +4981,11 @@ int ha_partition::rnd_pos(uchar * buf, uchar *pos)
int ha_partition::rnd_pos_by_record(uchar *record)
{
DBUG_ENTER("ha_partition::rnd_pos_by_record");

if (unlikely(get_part_for_delete(record, m_rec0, m_part_info, &m_last_part)))
DBUG_RETURN(1);

DBUG_RETURN(handler::rnd_pos_by_record(record));
DBUG_RETURN(m_file[m_last_part]->rnd_pos_by_record(record));
}


/****************************************************************************
MODULE index scan
****************************************************************************/
Expand Down
11 changes: 10 additions & 1 deletion sql/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2457,10 +2457,19 @@ class handler :public Sql_alloc
*/
virtual int rnd_pos_by_record(uchar *record)
{
int error;
DBUG_ASSERT(table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION);

error = ha_rnd_init(false);
if (error != 0)
return error;

position(record);
return ha_rnd_pos(record, ref);
error = ha_rnd_pos(record, ref);
ha_rnd_end();
return error;
}

virtual int read_first_row(uchar *buf, uint primary_key);
/**
The following function is only needed for tables that may be temporary
Expand Down
5 changes: 0 additions & 5 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10655,12 +10655,7 @@ int Rows_log_event::do_index_scan_and_update(Relay_log_info const *rli)
if (m_table->file->inited && (error= m_table->file->ha_index_end()))
goto end;

if ((error= m_table->file->ha_rnd_init(FALSE)))
goto end;

error= m_table->file->rnd_pos_by_record(m_table->record[0]);

m_table->file->ha_rnd_end();
if (error)
{
DBUG_PRINT("info",("rnd_pos returns error %d",error));
Expand Down

0 comments on commit aa61f56

Please sign in to comment.