24#ifndef CHANGESTREAM_APPLY_COMMIT_ORDER_QUEUE
25#define CHANGESTREAM_APPLY_COMMIT_ORDER_QUEUE
267 std::tuple<value_type, sequence_type>
pop();
Context of the owner of metadata locks.
Definition: mdl.h:1429
unsigned long long index_type
Definition: integrals_lockfree_queue.h:144
enum_queue_state
Definition: integrals_lockfree_queue.h:153
static constexpr value_type null_value
Definition: integrals_lockfree_queue.h:148
Iterator helper class to iterate over the Commit_order_queue following the underlying commit order.
Definition: commit_order_queue.h:171
Commit_order_queue * m_target
The target queue that holds the list to be iterated.
Definition: commit_order_queue.h:210
Iterator & operator=(const Iterator &rhs)
reference operator*()
Definition: commit_order_queue.cc:89
Commit_order_queue::queue_type::index_type index_type
Definition: commit_order_queue.h:178
virtual ~Iterator()=default
Iterator & operator++()
Definition: commit_order_queue.cc:83
bool operator!=(Iterator const &rhs) const
Definition: commit_order_queue.cc:114
pointer operator->()
Definition: commit_order_queue.cc:103
Commit_order_queue::queue_type::Iterator m_current
The iterator pointing to the underlying queue position.
Definition: commit_order_queue.h:212
std::ptrdiff_t difference_type
Definition: commit_order_queue.h:173
std::forward_iterator_tag iterator_category
Definition: commit_order_queue.h:177
Iterator(Commit_order_queue &parent, index_type position)
Definition: commit_order_queue.cc:58
bool operator==(Iterator const &rhs) const
Definition: commit_order_queue.cc:109
Iterator(const Iterator &rhs)
Queue element, holding the needed information to manage the commit ordering.
Definition: commit_order_queue.h:77
memory::Aligned_atomic< Commit_order_queue::sequence_type > m_commit_sequence_nr
The sequence number for the commit request this node's worker is processing.
Definition: commit_order_queue.h:141
value_type m_worker_id
The identifier of the worker that maps to a queue index.
Definition: commit_order_queue.h:82
Commit_order_queue::sequence_type reset_commit_sequence_nr()
Sets the commit request sequence number for this node as unassigned.
Definition: commit_order_queue.cc:44
memory::Aligned_atomic< Commit_order_queue::enum_worker_stage > m_stage
Which stage is the worker on.
Definition: commit_order_queue.h:86
bool freeze_commit_sequence_nr(Commit_order_queue::sequence_type expected)
Marks the commit request sequence number this node's worker is processing as frozen iff the sequence ...
Definition: commit_order_queue.cc:30
MDL_context * m_mdl_context
The MDL context to be used to wait on the MDL graph.
Definition: commit_order_queue.h:84
static constexpr Commit_order_queue::sequence_type NO_SEQUENCE_NR
Definition: commit_order_queue.h:134
static constexpr Commit_order_queue::sequence_type SEQUENCE_NR_FROZEN
Definition: commit_order_queue.h:136
bool unfreeze_commit_sequence_nr(Commit_order_queue::sequence_type previously_frozen)
Removes the frozen mark from the commit request sequence number this node's worker is processing if i...
Definition: commit_order_queue.cc:36
Queue to maintain the ordered sequence of workers waiting for commit.
Definition: commit_order_queue.h:55
std::vector< Commit_order_queue::Node > m_workers
The list of worker Nodes, indexed by worker ID.
Definition: commit_order_queue.h:343
virtual ~Commit_order_queue()=default
Default destructor for the class.
void unfreeze()
Releases exclusivity over changes (push, pop) on the queue.
Definition: commit_order_queue.cc:190
Iterator begin()
Retrieves an iterator instance that points to the head of the commit queue and that will iterate over...
Definition: commit_order_queue.cc:194
enum_worker_stage
Enumeration to represent each worker state.
Definition: commit_order_queue.h:66
unsigned long long sequence_type
Definition: commit_order_queue.h:59
std::string to_string()
Retrieves the textual representation of this object's underlying commit queue.
Definition: commit_order_queue.cc:204
void freeze()
Acquires exclusivity over changes (push, pop) on the queue.
Definition: commit_order_queue.cc:186
Iterator end()
Retrieves an iterator instance that points to the tail of the commit queue.
Definition: commit_order_queue.cc:199
static constexpr value_type NO_WORKER
Definition: commit_order_queue.h:60
Node & operator[](value_type id)
Retrieve the commit order information Node for worker identified by id.
Definition: commit_order_queue.cc:130
void push(value_type id)
Adds to the end of the commit queue the worker identifier passed as parameter.
Definition: commit_order_queue.cc:163
value_type front()
Retrieves the identifier of the worker that is first in-line to commit.
Definition: commit_order_queue.cc:180
memory::Aligned_atomic< sequence_type > m_commit_sequence_generator
The commit sequence number counter.
Definition: commit_order_queue.h:340
lock::Shared_spin_lock m_push_pop_lock
The lock to acquire exlusivity over changes on the queue.
Definition: commit_order_queue.h:347
friend std::ostream & operator<<(std::ostream &out, Commit_order_queue &to_output)
Friend operator for writing to an std::ostream object.
Definition: commit_order_queue.h:322
queue_type m_commit_queue
The queue to hold the sequence of worker IDs waiting to commit.
Definition: commit_order_queue.h:345
void clear()
Removes all remaining workers from the queue.
Definition: commit_order_queue.cc:184
bool is_empty()
Whether or not there are more workers to commit.
Definition: commit_order_queue.cc:142
static sequence_type get_next_sequence_nr(sequence_type current_seq_nr)
Returns the expected next number in the ticket sequence.
Definition: commit_order_queue.cc:209
unsigned long value_type
Definition: commit_order_queue.h:57
Commit_order_queue::queue_type::enum_queue_state get_state()
Retrieves the error state for the current thread last executed queue operation.
Definition: commit_order_queue.cc:138
Commit_order_queue(size_t n_workers)
Constructor for the class, takes the number of workers and initializes the underlying static list wit...
Definition: commit_order_queue.cc:119
std::tuple< value_type, sequence_type > pop()
Removes from the queue and returns the identifier of the worker that is first in-line to commit.
Definition: commit_order_queue.cc:148
Definition: shared_spin_lock.h:80
Templated class that encapsulates an std::atomic within a byte buffer that is padded to the processor...
Definition: aligned_atomic.h:158
Definition: commit_order_queue.h:34
static mysql_service_status_t flush(reference_caching_cache cache) noexcept
Definition: component.cc:114