MySQL 9.1.0
Source Code Documentation
mta_worker_metrics.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
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 CS_MTA_WORKER_METRICS_H
25#define CS_MTA_WORKER_METRICS_H
26#include <atomic>
27#include "worker_metrics.h"
28
29namespace cs::apply::instruments {
30
31/// @brief This class contains metrics transaction
32/// execution in replica MTA workers
34 public:
35 /// @brief Resets the instruments on this instance.
36 void reset() override;
37
38 /// @brief Returns the type of the currently being processed transaction
39 /// @return If the type is unknown, DML or DDL
41
42 /// @brief Set the type for the transaction being currently processed
43 /// @param type_info what is the type: UNKONWN, DML or DDL
44 void set_transaction_type(Transaction_type_info type_info) override;
45
46 /// @brief set the full size of the ongoing transaction.
47 /// @param amount new size
48 void set_transaction_ongoing_full_size(int64_t amount) override;
49
50 /// @brief Gets the full size of the ongoing transaction
51 /// @return the total size of the ongoing transaction
52 int64_t get_transaction_ongoing_full_size() const override;
53
54 /// @brief increment the executed size of the ongoing transaction.
55 /// @param amount the size amount to increment.
56 void inc_transaction_ongoing_progress_size(int64_t amount) override;
57
58 /// @brief Resets the the executed size of the ongoing transaction to 0
60
61 /// @brief Gets the executed size of the ongoing transaction
62 /// @return the exectuted size of the ongoing transaction
63 int64_t get_transaction_ongoing_progress_size() const override;
64
65 /// @brief Copies stats from the given object into this one.
66 /// @param other the object to copy the stats from.
67 void copy_stats_from(const Mta_worker_metrics &other);
68
69 /// @brief Gets the total time waited on commit order
70 /// @return the sum of the time waited on commit
71 int64_t get_wait_time_on_commit_order() const override;
72
73 /// @brief Increments the number of times waited
74 void inc_waited_time_on_commit_order(unsigned long amount) override;
75
76 /// @brief Get the number of time waiting on commit order
77 /// @return the counter of waits on commit order
78 int64_t get_number_of_waits_on_commit_order() const override;
79
80 /// @brief Increments the number of times waited
82
83 private:
84 /// @brief The type of the transactions being handled
85 std::atomic<Transaction_type_info> m_transaction_type{
87
88 /// @brief The number of time waited for commit order
89 std::atomic_int64_t m_order_commit_wait_count{0};
90
91 /// @brief The total amount of time waited for commit order
92 std::atomic_int64_t m_order_commit_waited_time{0};
93
94 /// @brief Holds the total full size of the transaction now ongoing
95 std::atomic_int64_t m_transaction_ongoing_full_size{0};
96
97 /// @brief Holds the executed event's size of the transaction now ongoing
99};
100} // namespace cs::apply::instruments
101
102#endif /* CS_MTA_WORKER_METRICS_H */
This class contains metrics transaction execution in replica MTA workers.
Definition: mta_worker_metrics.h:33
std::atomic_int64_t m_transaction_ongoing_full_size
Holds the total full size of the transaction now ongoing.
Definition: mta_worker_metrics.h:95
int64_t get_wait_time_on_commit_order() const override
Gets the total time waited on commit order.
Definition: mta_worker_metrics.cc:66
std::atomic_int64_t m_order_commit_wait_count
The number of time waited for commit order.
Definition: mta_worker_metrics.h:89
void reset_transaction_ongoing_progress_size() override
Resets the the executed size of the ongoing transaction to 0.
Definition: mta_worker_metrics.cc:58
void reset() override
Resets the instruments on this instance.
Definition: mta_worker_metrics.cc:28
void inc_transaction_ongoing_progress_size(int64_t amount) override
increment the executed size of the ongoing transaction.
Definition: mta_worker_metrics.cc:54
void inc_waited_time_on_commit_order(unsigned long amount) override
Increments the number of times waited.
Definition: mta_worker_metrics.cc:70
std::atomic_int64_t m_order_commit_waited_time
The total amount of time waited for commit order.
Definition: mta_worker_metrics.h:92
void set_transaction_ongoing_full_size(int64_t amount) override
set the full size of the ongoing transaction.
Definition: mta_worker_metrics.cc:46
std::atomic_int64_t m_transaction_ongoing_progress_size
Holds the executed event's size of the transaction now ongoing.
Definition: mta_worker_metrics.h:98
void inc_number_of_waits_on_commit_order() override
Increments the number of times waited.
Definition: mta_worker_metrics.cc:78
void set_transaction_type(Transaction_type_info type_info) override
Set the type for the transaction being currently processed.
Definition: mta_worker_metrics.cc:41
std::atomic< Transaction_type_info > m_transaction_type
The type of the transactions being handled.
Definition: mta_worker_metrics.h:85
int64_t get_transaction_ongoing_progress_size() const override
Gets the executed size of the ongoing transaction.
Definition: mta_worker_metrics.cc:62
Worker_metrics::Transaction_type_info get_transaction_type() const override
Returns the type of the currently being processed transaction.
Definition: mta_worker_metrics.cc:37
int64_t get_transaction_ongoing_full_size() const override
Gets the full size of the ongoing transaction.
Definition: mta_worker_metrics.cc:50
int64_t get_number_of_waits_on_commit_order() const override
Get the number of time waiting on commit order.
Definition: mta_worker_metrics.cc:74
void copy_stats_from(const Mta_worker_metrics &other)
Copies stats from the given object into this one.
Definition: mta_worker_metrics.cc:82
Abstract class for classes that contain metrics related to transaction execution in applier workers.
Definition: worker_metrics.h:33
Transaction_type_info
This class helps signaling a transactions as DDL or DML.
Definition: worker_metrics.h:36
Definition: applier_metrics.cc:27