Skip to content

Commit

Permalink
MDEV-35157 : wrong binlog timestamps on secondary nodes of a galera c…
Browse files Browse the repository at this point in the history
…luster

Problem was missing thd->set_time() before binlog event
execution in wsrep_apply_events.

Removed part of earlier commit 1363580 because it had
nothing to do with VERSIONED tables.

Note that this commit does not contain mtr-testcase
because actual timestamps on binlog file depends the
actual time when events are executed and how long
their execution takes.

e
  • Loading branch information
janlindstrom committed Oct 31, 2024
1 parent c3a7a3c commit 8e07f6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
15 changes: 3 additions & 12 deletions sql/log_event_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1721,10 +1721,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
Gtid_log_event::FL_COMPLETED_XA))) ||
rpl_filter->db_ok(thd->db.str))
{
#ifdef WITH_WSREP
if (!wsrep_thd_is_applying(thd))
#endif
thd->set_time(when, when_sec_part);
thd->set_time(when, when_sec_part);
thd->set_query_and_id((char*)query_arg, q_len_arg,
thd->charset(), next_query_id());
thd->variables.pseudo_thread_id= thread_id; // for temp tables
Expand Down Expand Up @@ -2863,10 +2860,7 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
*/
if (rpl_filter->db_ok(thd->db.str))
{
#ifdef WITH_WSREP
if (!wsrep_thd_is_applying(thd))
#endif
thd->set_time(when, when_sec_part);
thd->set_time(when, when_sec_part);
thd->set_query_id(next_query_id());
thd->get_stmt_da()->opt_clear_warning_info(thd->query_id);

Expand Down Expand Up @@ -5701,10 +5695,7 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
TIMESTAMP column to a table with one.
So we call set_time(), like in SBR. Presently it changes nothing.
*/
#ifdef WITH_WSREP
if (!wsrep_thd_is_applying(thd))
#endif
thd->set_time(when, when_sec_part);
thd->set_time(when, when_sec_part);

if (m_width == table->s->fields && bitmap_is_set_all(&m_cols))
set_flags(COMPLETE_ROWS_F);
Expand Down
12 changes: 11 additions & 1 deletion sql/wsrep_applier.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2013-2019 Codership Oy <[email protected]>
/* Copyright (C) 2013-2024 Codership Oy <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -211,7 +211,17 @@ int wsrep_apply_events(THD* thd,
}

ev->thd= thd;
thd->set_time();

if (!ev->when)
{
my_hrtime_t hrtime= my_hrtime();
ev->when= hrtime_to_my_time(hrtime);
ev->when_sec_part= hrtime_sec_part(hrtime);
}

exec_res= ev->apply_event(thd->wsrep_rgi);

DBUG_PRINT("info", ("exec_event result: %d", exec_res));

if (exec_res)
Expand Down
1 change: 0 additions & 1 deletion sql/wsrep_high_priority_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ int Wsrep_high_priority_service::start_transaction(
const wsrep::ws_handle& ws_handle, const wsrep::ws_meta& ws_meta)
{
DBUG_ENTER(" Wsrep_high_priority_service::start_transaction");
m_thd->set_time();
DBUG_RETURN(m_thd->wsrep_cs().start_transaction(ws_handle, ws_meta) ||
trans_begin(m_thd));
}
Expand Down

0 comments on commit 8e07f6b

Please sign in to comment.