MySQL 26.7.0
Source Code Documentation
transaction_order_schedule.h
Go to the documentation of this file.
1// Copyright (c) 2026, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24#ifndef MYSQL_SCHEDULER_TRANSACTION_ORDER_SCHEDULE_H
25#define MYSQL_SCHEDULER_TRANSACTION_ORDER_SCHEDULE_H
26
27#include <chrono>
28#include <iostream>
29#include <memory>
30#include <string>
31
35
36namespace mysql::scheduler {
37
38/// @class Transaction_order_schedule
39/// @brief Represents schedule for a transaction executing in two phases:
40/// apply and committing, where commit must follow the commit order
42 public:
43 enum class Phase { prepare = 0, commit = 1 };
44 /// @brief Constructor
45 /// @details constructs schedule for tranctions executing commit order
46 /// @param task_id Task identifier
47 /// @param trx_clock Clock transaction schedule is based on
48 /// @param trx_time Delay w.r.t. trx_clock start point
49 /// @param commit_clock Clock transaction commit schedule is based on
50 /// @param commit_time Delay w.r.t. trx_clock start point
52 uint64_t trx_time,
53 Scheduler_clock_ptr commit_clock,
54 uint64_t commit_time);
55
56 /// @brief This function modifies the state of the schedule to next state
57 /// @returns false - Task is one-shot task, won't be executed in the future
58 bool next() override;
59
60 /// @brief Gets information about next execution time
61 /// @returns Current phase task delay
62 const Time_delay_type &get_task_delay() const override;
63
64 bool is_finished() const override;
65
66 /// @brief Obtain task clock
67 const Scheduler_clock_ptr &get_clock() const override;
68
69 /// @brief Obtain task id
70 const Task_id &get_id() const override;
71
72 /// @brief Gets information about execution time in specific phase
73 /// @param phase_id Selected phase sequence number
74 const Time_delay_type &get_phase_delay(unsigned int phase_id) const override;
75
76 /// @brief Obtain task clock for the given phase id
77 /// @param phase_id Selected phase sequence number
79 unsigned int phase_id) const override;
80
81 /// @brief Returns current phase id (sequence number)
82 /// @return Phase sequence number
83 unsigned int get_phase_id() const override;
84
85 protected:
86 private:
87 /// This task id
89 /// Clock whole task schedule is based on
91 /// Transaction start execution time, relative to the m_trx_clock
92 uint64_t m_trx_time;
93 /// Commit clock, dependency clock for commit phase
95 /// Transaction commit start time, relative to the commit clock
96 uint64_t m_commit_time;
97 /// Current schedule phase
98 unsigned int m_phase{0};
99};
100
101} // namespace mysql::scheduler
102
103#endif // MYSQL_SCHEDULER_TRANSACTION_ORDER_SCHEDULE_H
Represents the identifier of a task ingested by the scheduler,.
Definition: task_id.h:41
Represents task schedule.
Definition: task_schedule.h:45
Represents schedule for a transaction executing in two phases: apply and committing,...
Definition: transaction_order_schedule.h:41
Transaction_order_schedule(Task_id task_id, Scheduler_clock_ptr trx_clock, uint64_t trx_time, Scheduler_clock_ptr commit_clock, uint64_t commit_time)
Constructor.
Definition: transaction_order_schedule.cpp:31
Scheduler_clock_ptr m_trx_clock
Clock whole task schedule is based on.
Definition: transaction_order_schedule.h:90
Scheduler_clock_ptr m_commit_clock
Commit clock, dependency clock for commit phase.
Definition: transaction_order_schedule.h:94
const Time_delay_type & get_task_delay() const override
Gets information about next execution time.
Definition: transaction_order_schedule.cpp:55
bool next() override
This function modifies the state of the schedule to next state.
Definition: transaction_order_schedule.cpp:47
unsigned int m_phase
Current schedule phase.
Definition: transaction_order_schedule.h:98
bool is_finished() const override
Definition: transaction_order_schedule.cpp:40
uint64_t m_commit_time
Transaction commit start time, relative to the commit clock.
Definition: transaction_order_schedule.h:96
Phase
Definition: transaction_order_schedule.h:43
const Time_delay_type & get_phase_delay(unsigned int phase_id) const override
Gets information about execution time in specific phase.
Definition: transaction_order_schedule.cpp:65
Task_id m_task_id
This task id.
Definition: transaction_order_schedule.h:88
unsigned int get_phase_id() const override
Returns current phase id (sequence number)
Definition: transaction_order_schedule.cpp:81
const Scheduler_clock_ptr & get_clock() const override
Obtain task clock.
Definition: transaction_order_schedule.cpp:59
uint64_t m_trx_time
Transaction start execution time, relative to the m_trx_clock.
Definition: transaction_order_schedule.h:92
const Task_id & get_id() const override
Obtain task id.
Definition: transaction_order_schedule.cpp:63
const Scheduler_clock_ptr & get_phase_clock(unsigned int phase_id) const override
Obtain task clock for the given phase id.
Definition: transaction_order_schedule.cpp:73
Definition: base_dependency_tracker.h:41
std::uint64_t Time_delay_type
Time points are created as a delay from a specific start time (clock relative measure)
Definition: time.h:39
std::shared_ptr< Scheduler_clock > Scheduler_clock_ptr
Definition: scheduler_clock.h:36