34#ifndef ut0stateful_latching_rules
35#define ut0stateful_latching_rules
112template <
typename Node,
size_t LATCHES_COUNT>
168 template <
typename T>
172 for (
size_t i = 0; i < latches.size(); ++i) {
202 if (
source.count(edge.m_from) && destination.count(edge.m_to) &&
203 (edge.m_latches & forbiden_latches) == 0) {
206 the_err <<
"It is possible to transition from " << edge.m_from
207 <<
" to " << edge.m_to <<
" holding just ";
208 print(the_err, edge.m_latches);
209 the_err <<
" even when we hold ";
210 print(the_err, forbiden_latches);
227 std::inserter(other_states, other_states.end()));
260 std::vector<edge_t> allowed_transitions)
276 const bool can_leave_A =
can_leave(owned_latches, A);
277 const bool can_leave_B =
can_leave(owned_latches, B);
279 if (can_leave_A || can_leave_B) {
281 the_err <<
"We can leave "
282 << (can_leave_A && can_leave_B ?
"both A and B"
283 : (can_leave_A ?
"A" :
"B"))
284 <<
" as we only hold: ";
285 print(the_err, owned_latches);
309 const auto missing_latches = ~owned_latches;
312 return (edge.m_from == from && edge.m_to == to) &&
313 (edge.m_latches & missing_latches) == 0;
318 the_err <<
"Disallowed transition FROM " << from <<
" TO " << to
320 print(the_err, owned_latches);
The class error is used to emit error messages.
Definition: ut0log.h:230
The class fatal is used to emit an error message and stop the server by crashing it.
Definition: ut0log.h:252
This is a generic mechanism for verifying correctness of latching rules for state transitions and que...
Definition: ut0stateful_latching_rules.h:113
const nodes_set_t m_states
The set of all possible states.
Definition: ut0stateful_latching_rules.h:158
const std::vector< edge_t > m_edges
The list of allowed state transitions.
Definition: ut0stateful_latching_rules.h:161
std::bitset< LATCHES_COUNT > latches_set_t
The type for a set of latches - there are LATCHES_COUNT distinct latches, each one corresponds to a f...
Definition: ut0stateful_latching_rules.h:124
bool is_transition_possible(const latches_set_t &forbiden_latches, const nodes_set_t &source, const nodes_set_t &destination) const
Checks if another thread could change the state even though we hold some latches.
Definition: ut0stateful_latching_rules.h:198
void assert_latches_let_distinguish(const latches_set_t &owned_latches, const nodes_set_t &A, const nodes_set_t &B) const
Checks if owned_latches (presumably held by the current thread) are enough to meaningfully ask a ques...
Definition: ut0stateful_latching_rules.h:273
Stateful_latching_rules(nodes_set_t all_states, std::vector< edge_t > allowed_transitions)
Creates a set of rules for allowed_transitions between all_states.
Definition: ut0stateful_latching_rules.h:259
nodes_set_t complement(const nodes_set_t &states) const
Computes the complement of the given set of states, that is a set of all of the other states.
Definition: ut0stateful_latching_rules.h:223
Node node_t
The type for a state in our automata.
Definition: ut0stateful_latching_rules.h:116
std::set< node_t > nodes_set_t
The type for a set of states.
Definition: ut0stateful_latching_rules.h:119
void assert_latches_let_distinguish(const latches_set_t &owned_latches, const nodes_set_t &A) const
A convenience function for the special case of.
Definition: ut0stateful_latching_rules.h:295
void on_transition(const node_t &from, const node_t &to, const latches_set_t &owned_latches) const
Checks if the transition between given states holding specified latches is allowed by the rules.
Definition: ut0stateful_latching_rules.h:304
void print(T &sout, const latches_set_t &latches) const
A helper function which prints the ids of latches from the set of latches to an ostream-like object (...
Definition: ut0stateful_latching_rules.h:169
bool can_leave(const latches_set_t &forbiden_latches, const nodes_set_t &source) const
A convenience function for the special case of.
Definition: ut0stateful_latching_rules.h:242
void * begin(THD *thd, const TABLE *table, size_t data_size, size_t memory, size_t num_threads) noexcept
Definition: bulk_data_service.cc:1533
Definition: varlen_sort.h:183
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:47
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:41
The type for a possible transition from one state to another while holding at least a given set of la...
Definition: ut0stateful_latching_rules.h:128
node_t m_to
The new state from to which the transition leads.
Definition: ut0stateful_latching_rules.h:138
edge_t(node_t from, std::initializer_list< int > &&idxs, node_t to)
Creates a description of one of allowed state transitions from given state to another while holding g...
Definition: ut0stateful_latching_rules.h:149
node_t m_from
The old state from which the transition starts.
Definition: ut0stateful_latching_rules.h:130
latches_set_t m_latches
The required subset of latches for this particular transition.
Definition: ut0stateful_latching_rules.h:135
#define UT_LOCATION_HERE
Definition: ut0core.h:72
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:509