Skip to content

MDEV-20065 parallel replication for galera slave #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 10.11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sql/wsrep_mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3980,6 +3980,16 @@ bool THD::wsrep_parallel_slave_wait_for_prior_commit()
return false;
}

void wsrep_parallel_slave_wakeup_subsequent_commits(void *thd_ptr)
{
THD *thd = (THD*)thd_ptr;
if (thd->rgi_slave && thd->rgi_slave->is_parallel_exec &&
thd->wait_for_commit_ptr)
{
thd->wait_for_commit_ptr->wakeup_subsequent_commits(0);
}
}

/***** callbacks for wsrep service ************/

my_bool get_wsrep_recovery()
Expand Down
9 changes: 7 additions & 2 deletions sql/wsrep_trans_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
class THD;

void wsrep_commit_empty(THD* thd, bool all);
void wsrep_parallel_slave_wakeup_subsequent_commits(void *);

/*
Return true if THD has active wsrep transaction.
Expand Down Expand Up @@ -265,7 +266,9 @@ static inline int wsrep_before_prepare(THD* thd, bool all)
{
DBUG_RETURN(ret);
}
if ((ret= thd->wsrep_cs().before_prepare()) == 0)
wsrep::provider::seq_cb_t seq_cb{
thd, wsrep_parallel_slave_wakeup_subsequent_commits};
if ((ret= thd->wsrep_cs().before_prepare(&seq_cb)) == 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@temeo Here we provide callback to Galera library but how the sequential consistency is maintained because this is called out-of-order? When the actual critical section is released, is it then on before_commit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback is effective only for parallel slave workers, see https://github.com/codership/mariadb-server/pull/459/files#diff-adadb13c7a06c1a6d6be490308b4cb130848c6e0b2ccca48dde12efeda10a498R3926. The workers call wait_for_prior_commit() from thd->wsrep_parallel_slave_wait_for_prior_commit() couple of lines above this, which makes workers' calls to before_prepare() serialized.

{
DBUG_ASSERT(!thd->wsrep_trx().ws_meta().gtid().is_undefined());
wsrep_xid_init(&thd->wsrep_xid,
Expand Down Expand Up @@ -314,7 +317,9 @@ static inline int wsrep_before_commit(THD* thd, bool all)
int ret= 0;
DBUG_ASSERT(wsrep_run_commit_hook(thd, all));

if ((ret= thd->wsrep_cs().before_commit()) == 0)
wsrep::provider::seq_cb_t seq_cb{
thd, wsrep_parallel_slave_wakeup_subsequent_commits};
if ((ret= thd->wsrep_cs().before_commit(&seq_cb)) == 0)
{
DBUG_ASSERT(!thd->wsrep_trx().ws_meta().gtid().is_undefined());
if (!thd->variables.gtid_seq_no &&
Expand Down