Skip to content

Commit

Permalink
Add 2pc switch to dbsim, release critical section in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
temeo committed Nov 28, 2024
1 parent 0f53cc0 commit aa122bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
18 changes: 16 additions & 2 deletions dbsim/db_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ int db::client::client_command(F f)
return err;
}

static void release_commit_critical_section(void* ptr)
{
auto* crit = static_cast<db::server::commit_critical_section*>(ptr);
if (crit->lock.owns_lock())
{
crit->lock.unlock();
}
}

void db::client::run_one_transaction()
{
if (params_.sync_wait)
Expand Down Expand Up @@ -152,10 +161,15 @@ void db::client::run_one_transaction()
commit_crit.lock.unlock();
}

wsrep::provider::seq_cb seq_cb {
&commit_crit,
release_commit_critical_section
};

assert(err == 0);
if (do_2pc())
if (params_.do_2pc)
{
err = err || client_state_.before_prepare();
err = err || client_state_.before_prepare(&seq_cb);
err = err || client_state_.after_prepare();
}
err = err || client_state_.before_commit();
Expand Down
1 change: 0 additions & 1 deletion dbsim/db_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ namespace db
void start();
wsrep::client_state& client_state() { return client_state_; }
wsrep::client_service& client_service() { return client_service_; }
bool do_2pc() const { return false; }
private:
friend class db::server_state;
friend class db::client_service;
Expand Down
3 changes: 3 additions & 0 deletions dbsim/db_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ db::params db::parse_args(int argc, char** argv)
("check-sequential-consistency",
po::value<bool>(&params.check_sequential_consistency),
"Check if the provider provides sequential consistency")
("do-2pc",
po::value<bool>(&params.do_2pc),
"Run commits in 2pc")
;
try
{
Expand Down
1 change: 1 addition & 0 deletions dbsim/db_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace db
bool cond_checks{false};
int tls_service{0};
bool check_sequential_consistency{false};
bool do_2pc{false};
};

params parse_args(int argc, char** argv);
Expand Down

0 comments on commit aa122bf

Please sign in to comment.