24#ifndef CHANGESTREAM_APPLY_COMMIT_ORDER_QUEUE
25#define CHANGESTREAM_APPLY_COMMIT_ORDER_QUEUE
275 std::tuple<value_type, sequence_type>
pop();
Context of the owner of metadata locks.
Definition: mdl.h:1415
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:178
Commit_order_queue * m_target
The target queue that holds the list to be iterated.
Definition: commit_order_queue.h:217
Iterator & operator=(const Iterator &rhs)
reference operator*()
Definition: commit_order_queue.cc:93
Commit_order_queue::queue_type::index_type index_type
Definition: commit_order_queue.h:185
virtual ~Iterator()=default
Iterator & operator++()
Definition: commit_order_queue.cc:87
bool operator!=(Iterator const &rhs) const
Definition: commit_order_queue.cc:118
pointer operator->()
Definition: commit_order_queue.cc:107
Commit_order_queue::queue_type::Iterator m_current
The iterator pointing to the underlying queue position.
Definition: commit_order_queue.h:219
std::ptrdiff_t difference_type
Definition: commit_order_queue.h:180
std::forward_iterator_tag iterator_category
Definition: commit_order_queue.h:184
Iterator(Commit_order_queue &parent, index_type position)
Definition: commit_order_queue.cc:62
bool operator==(Iterator const &rhs) const
Definition: commit_order_queue.cc:113
Iterator(const Iterator &rhs)
Queue element, holding the needed information to manage the commit ordering.
Definition: commit_order_queue.h:78
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:142
value_type m_worker_id
The identifier of the worker that maps to a queue index.
Definition: commit_order_queue.h:83
memory::Aligned_atomic< Commit_order_queue::sequence_type > m_next_commit_sequence_nr
The sequence number for the commit request of the worker scheduled after this one.
Definition: commit_order_queue.h:147
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:87
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:85
static constexpr Commit_order_queue::sequence_type NO_SEQUENCE_NR
Definition: commit_order_queue.h:135
static constexpr Commit_order_queue::sequence_type SEQUENCE_NR_FROZEN
Definition: commit_order_queue.h:137
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:362
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:198
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:202
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:212
void freeze()
Acquires exclusivity over changes (push, pop) on the queue.
Definition: commit_order_queue.cc:194
Iterator end()
Retrieves an iterator instance that points to the tail of the commit queue.
Definition: commit_order_queue.cc:207
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:134
std::tuple< value_type, value_type > remove_from_commit_queue(value_type to_remove)
Removes from the commit queue the first identifier that is equal to index.
Definition: commit_order_queue.cc:273
void push(value_type id)
Adds to the end of the commit queue the worker identifier passed as parameter.
Definition: commit_order_queue.cc:166
value_type front()
Retrieves the identifier of the worker that is first in-line to commit.
Definition: commit_order_queue.cc:185
memory::Aligned_atomic< sequence_type > m_commit_sequence_generator
The commit sequence number counter.
Definition: commit_order_queue.h:359
lock::Shared_spin_lock m_push_pop_lock
The lock to acquire exlusivity over changes on the queue.
Definition: commit_order_queue.h:366
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:330
queue_type m_commit_queue
The queue to hold the sequence of worker IDs waiting to commit.
Definition: commit_order_queue.h:364
void clear()
Removes all remaining workers from the queue.
Definition: commit_order_queue.cc:192
bool is_empty()
Whether or not there are more workers to commit.
Definition: commit_order_queue.cc:146
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:217
unsigned long value_type
Definition: commit_order_queue.h:57
std::tuple< value_type, sequence_type > remove(value_type index)
Removes from the queue and returns the first identifier of the worker that is equal to index.
Definition: commit_order_queue.cc:228
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:142
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:123
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:152
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