1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-31 18:24:25 +03:00

More strict check for read-only

Only local transactions can be RO
This commit is contained in:
Teemu Ollakka
2023-04-04 10:27:21 +03:00
parent 12c8069f09
commit 0f68da366e
2 changed files with 6 additions and 5 deletions

View File

@ -238,7 +238,7 @@ namespace wsrep
wsrep::provider& provider(); wsrep::provider& provider();
void flags(int flags) { flags_ = flags; } void flags(int flags) { flags_ = flags; }
bool is_read_only() const; bool is_local_read_only() const;
int before_commit_local_read_only(wsrep::unique_lock<wsrep::mutex>&); int before_commit_local_read_only(wsrep::unique_lock<wsrep::mutex>&);
int before_commit_local(wsrep::unique_lock<wsrep::mutex>&); int before_commit_local(wsrep::unique_lock<wsrep::mutex>&);
int before_commit_high_priority(wsrep::unique_lock<wsrep::mutex>&); int before_commit_high_priority(wsrep::unique_lock<wsrep::mutex>&);

View File

@ -438,9 +438,10 @@ int wsrep::transaction::after_prepare(
return ret; return ret;
} }
bool wsrep::transaction::is_read_only() const bool wsrep::transaction::is_local_read_only() const
{ {
return sr_keys_.empty(); return client_state_.mode() == wsrep::client_state::m_local
&& sr_keys_.empty();
} }
int wsrep::transaction::before_commit_local_read_only( int wsrep::transaction::before_commit_local_read_only(
@ -465,7 +466,7 @@ int wsrep::transaction::before_commit_local(
{ {
assert(lock.owns_lock()); assert(lock.owns_lock());
if (is_read_only()) { if (is_local_read_only()) {
return before_commit_local_read_only(lock); return before_commit_local_read_only(lock);
} }
@ -597,7 +598,7 @@ int wsrep::transaction::ordered_commit()
debug_log_state("ordered_commit_enter"); debug_log_state("ordered_commit_enter");
assert(state() == s_committing); assert(state() == s_committing);
if (is_read_only()) if (is_local_read_only())
{ {
state(lock, s_ordered_commit); state(lock, s_ordered_commit);
debug_log_state("ordered_commit_leave read_only"); debug_log_state("ordered_commit_leave read_only");