MySQL 9.0.0
Source Code Documentation
pfs_host.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2024, 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
25#ifndef PFS_HOST_H
26#define PFS_HOST_H
27
28/**
29 @file storage/perfschema/pfs_host.h
30 Performance schema host (declarations).
31*/
32
33#include <sys/types.h>
34#include <atomic>
35
36#include "lf.h"
37#include "my_hostname.h" /* HOSTNAME_LENGTH */
38#include "my_inttypes.h"
39#include "mysql_com.h"
44
45struct PFS_global_param;
49struct PFS_thread;
50struct PFS_account;
51
52/**
53 @addtogroup performance_schema_buffers
54 @{
55*/
56
57/** Hash key for a host. */
59 /** Host name. */
61};
62
63/** Per host statistics. */
65 public:
66 inline void init_refcount() { m_refcount.store(1); }
67
68 inline int get_refcount() { return m_refcount.load(); }
69
70 inline void inc_refcount() { ++m_refcount; }
71
72 inline void dec_refcount() { --m_refcount; }
73
74 void aggregate(bool alive);
75 void aggregate_waits();
76 void aggregate_stages();
77 void aggregate_statements();
78 void aggregate_transactions();
79 void aggregate_errors();
80 void aggregate_memory(bool alive);
81 void aggregate_status();
82 void aggregate_stats();
83 void release();
84
85 /** Reset all memory statistics. */
86 void rebase_memory_stats();
87
88 void carry_memory_stat_alloc_delta(PFS_memory_stat_alloc_delta *delta,
89 uint index);
90 void carry_memory_stat_free_delta(PFS_memory_stat_free_delta *delta,
91 uint index);
92
94 m_has_memory_stats = false;
95 m_instr_class_memory_stats = array;
96 }
97
99 if (!m_has_memory_stats) {
100 return nullptr;
101 }
102 return m_instr_class_memory_stats;
103 }
104
106 if (!m_has_memory_stats) {
107 rebase_memory_stats();
108 m_has_memory_stats = true;
109 }
110 return m_instr_class_memory_stats;
111 }
112
113 /* Internal lock. */
116
118 m_disconnected_count = 0;
119 m_max_controlled_memory = 0;
120 m_max_total_memory = 0;
121 }
122
123 void aggregate_stats_from(PFS_account *pfs);
124 void aggregate_disconnect(ulonglong controlled_memory,
125 ulonglong total_memory);
126
130
131 private:
132 std::atomic<int> m_refcount;
133
134 /**
135 Per host memory aggregated statistics.
136 This member holds the data for the table
137 PERFORMANCE_SCHEMA.MEMORY_SUMMARY_BY_HOST_BY_EVENT_NAME.
138 Immutable, safe to use without internal lock.
139 */
140 PFS_memory_shared_stat *m_instr_class_memory_stats{nullptr};
141};
142
143int init_host(const PFS_global_param *param);
144void cleanup_host();
145int init_host_hash(const PFS_global_param *param);
146void cleanup_host_hash();
147
149
151void purge_all_host();
152
153/* For show status. */
154
155extern LF_HASH host_hash;
156
157/** @} */
158#endif
PFS_host * sanitize_host(PFS_host *unsafe)
Definition: pfs_host.cc:372
int init_host_hash(const PFS_global_param *param)
Initialize the host hash.
Definition: pfs_host.cc:123
void cleanup_host_hash()
Cleanup the host hash.
Definition: pfs_host.cc:134
void cleanup_host()
Cleanup all the host buffers.
Definition: pfs_host.cc:67
int init_host(const PFS_global_param *param)
Initialize the host buffers.
Definition: pfs_host.cc:58
LF_HASH host_hash
Definition: pfs_host.cc:50
void purge_all_host()
Purge non connected hosts, reset stats of connected hosts.
Definition: pfs_host.cc:413
PFS_host * find_or_create_host(PFS_thread *thread, const PFS_host_name *host)
Definition: pfs_host.cc:155
Common definition used by mysys, performance schema and server & client.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Common definition between mysql server & client.
const char * host
Definition: mysqladmin.cc:65
Performance schema connection slice (declarations).
Miscellaneous global dependencies (declarations).
#define PFS_ALIGNED
Definition: pfs_global.h:57
Performance schema internal locks (declarations).
Object names (declarations).
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
Definition: lf.h:187
Per account statistics.
Definition: pfs_account.h:67
A connection slice, an arbitrary grouping of several connections.
Definition: pfs_con_slice.h:54
Performance schema global sizing parameters.
Definition: pfs_server.h:120
Hash key for a host.
Definition: pfs_host.h:58
PFS_host_name m_host_name
Host name.
Definition: pfs_host.h:60
Definition: pfs_name.h:522
Per host statistics.
Definition: pfs_host.h:64
PFS_host_key m_key
Definition: pfs_host.h:115
pfs_lock m_lock
Definition: pfs_host.h:114
PFS_memory_shared_stat * write_instr_class_memory_stats()
Definition: pfs_host.h:105
void inc_refcount()
Definition: pfs_host.h:70
ulonglong m_max_total_memory
Definition: pfs_host.h:129
void dec_refcount()
Definition: pfs_host.h:72
void init_refcount()
Definition: pfs_host.h:66
void set_instr_class_memory_stats(PFS_memory_shared_stat *array)
Definition: pfs_host.h:93
ulonglong m_disconnected_count
Definition: pfs_host.h:127
const PFS_memory_shared_stat * read_instr_class_memory_stats() const
Definition: pfs_host.h:98
void reset_connections_stats()
Definition: pfs_host.h:117
int get_refcount()
Definition: pfs_host.h:68
std::atomic< int > m_refcount
Definition: pfs_host.h:132
ulonglong m_max_controlled_memory
Definition: pfs_host.h:128
Definition: pfs_stat.h:937
Definition: pfs_stat.h:883
Definition: pfs_stat.h:888
Instrumented thread implementation.
Definition: pfs_instr.h:375
A 'lock' protecting performance schema internal buffers.
Definition: pfs_lock.h:154
static void alive(server *s)
Definition: xcom_transport.cc:174