1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

Collect and append SR commit keys.

This commit is contained in:
Teemu Ollakka
2018-07-09 20:16:31 +03:00
parent 6f68c70d37
commit 8c4a786f79
3 changed files with 87 additions and 3 deletions

View File

@ -98,6 +98,7 @@ wsrep::transaction::transaction(
, pa_unsafe_(false)
, certified_(false)
, streaming_context_()
, sr_keys_()
{ }
@ -192,7 +193,16 @@ int wsrep::transaction::start_replaying(const wsrep::ws_meta& ws_meta)
int wsrep::transaction::append_key(const wsrep::key& key)
{
/** @todo Collect table level keys for SR commit */
return provider().append_key(ws_handle_, key);
try
{
sr_keys_.insert(key);
return provider().append_key(ws_handle_, key);
}
catch (...)
{
wsrep::log_error() << "Failed to append key";
return 1;
}
}
int wsrep::transaction::append_data(const wsrep::const_buffer& data)
@ -954,11 +964,17 @@ int wsrep::transaction::certify_commit(
}
state(lock, s_certifying);
lock.unlock();
if (is_streaming())
{
append_sr_keys_for_commit();
flags(flags() | wsrep::provider::flag::pa_unsafe);
}
sr_keys_.clear();
flags(flags() | wsrep::provider::flag::commit);
lock.unlock();
if (client_service_.prepare_data_for_replication())
{
lock.lock();
@ -1100,6 +1116,27 @@ int wsrep::transaction::certify_commit(
return ret;
}
int wsrep::transaction::append_sr_keys_for_commit()
{
int ret(0);
assert(client_state_.mode() == wsrep::client_state::m_local);
for (wsrep::sr_key_set::branch_type::const_iterator
i(sr_keys_.root().begin());
ret == 0 && i != sr_keys_.root().end(); ++i)
{
for (wsrep::sr_key_set::leaf_type::const_iterator
j(i->second.begin());
ret == 0 && j != i->second.end(); ++j)
{
wsrep::key key(wsrep::key::shared);
key.append_key_part(i->first.data(), i->first.size());
key.append_key_part(j->data(), j->size());
ret = provider().append_key(ws_handle_, key);
}
}
return ret;
}
void wsrep::transaction::streaming_rollback()
{
assert(streaming_context_.rolled_back() == false);