MySQL 8.2.0
Source Code Documentation
pfs_host.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef PFS_HOST_H
25#define PFS_HOST_H
26
27/**
28 @file storage/perfschema/pfs_host.h
29 Performance schema host (declarations).
30*/
31
32#include <sys/types.h>
33#include <atomic>
34
35#include "lf.h"
36#include "my_hostname.h" /* HOSTNAME_LENGTH */
37#include "my_inttypes.h"
38#include "mysql_com.h"
43
44struct PFS_global_param;
48struct PFS_thread;
49struct PFS_account;
50
51/**
52 @addtogroup performance_schema_buffers
53 @{
54*/
55
56/** Hash key for a host. */
58 /** Host name. */
60};
61
62/** Per host statistics. */
64 public:
65 inline void init_refcount() { m_refcount.store(1); }
66
67 inline int get_refcount() { return m_refcount.load(); }
68
69 inline void inc_refcount() { ++m_refcount; }
70
71 inline void dec_refcount() { --m_refcount; }
72
73 void aggregate(bool alive);
74 void aggregate_waits();
75 void aggregate_stages();
76 void aggregate_statements();
77 void aggregate_transactions();
78 void aggregate_errors();
79 void aggregate_memory(bool alive);
80 void aggregate_status();
81 void aggregate_stats();
82 void release();
83
84 /** Reset all memory statistics. */
85 void rebase_memory_stats();
86
87 void carry_memory_stat_alloc_delta(PFS_memory_stat_alloc_delta *delta,
88 uint index);
89 void carry_memory_stat_free_delta(PFS_memory_stat_free_delta *delta,
90 uint index);
91
93 m_has_memory_stats = false;
94 m_instr_class_memory_stats = array;
95 }
96
98 if (!m_has_memory_stats) {
99 return nullptr;
100 }
101 return m_instr_class_memory_stats;
102 }
103
105 if (!m_has_memory_stats) {
106 rebase_memory_stats();
107 m_has_memory_stats = true;
108 }
109 return m_instr_class_memory_stats;
110 }
111
112 /* Internal lock. */
115
117 m_disconnected_count = 0;
118 m_max_controlled_memory = 0;
119 m_max_total_memory = 0;
120 }
121
122 void aggregate_stats_from(PFS_account *pfs);
123 void aggregate_disconnect(ulonglong controlled_memory,
124 ulonglong total_memory);
125
129
130 private:
131 std::atomic<int> m_refcount;
132
133 /**
134 Per host memory aggregated statistics.
135 This member holds the data for the table
136 PERFORMANCE_SCHEMA.MEMORY_SUMMARY_BY_HOST_BY_EVENT_NAME.
137 Immutable, safe to use without internal lock.
138 */
140};
141
142int init_host(const PFS_global_param *param);
143void cleanup_host();
144int init_host_hash(const PFS_global_param *param);
145void cleanup_host_hash();
146
148
150void purge_all_host();
151
152/* For show status. */
153
154extern LF_HASH host_hash;
155
156/** @} */
157#endif
PFS_host * sanitize_host(PFS_host *unsafe)
Definition: pfs_host.cc:371
int init_host_hash(const PFS_global_param *param)
Initialize the host hash.
Definition: pfs_host.cc:122
void cleanup_host_hash()
Cleanup the host hash.
Definition: pfs_host.cc:133
void cleanup_host()
Cleanup all the host buffers.
Definition: pfs_host.cc:66
int init_host(const PFS_global_param *param)
Initialize the host buffers.
Definition: pfs_host.cc:57
LF_HASH host_hash
Definition: pfs_host.cc:49
void purge_all_host()
Purge non connected hosts, reset stats of connected hosts.
Definition: pfs_host.cc:412
PFS_host * find_or_create_host(PFS_thread *thread, const PFS_host_name *host)
Definition: pfs_host.cc:154
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:55
Common definition between mysql server & client.
const char * host
Definition: mysqladmin.cc:63
Performance schema connection slice (declarations).
Miscellaneous global dependencies (declarations).
#define PFS_ALIGNED
Definition: pfs_global.h:56
Performance schema internal locks (declarations).
Object names (declarations).
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:65
Definition: lf.h:186
Per account statistics.
Definition: pfs_account.h:66
A connection slice, an arbitrary grouping of several connections.
Definition: pfs_con_slice.h:53
Performance schema global sizing parameters.
Definition: pfs_server.h:118
Hash key for a host.
Definition: pfs_host.h:57
PFS_host_name m_host_name
Host name.
Definition: pfs_host.h:59
Definition: pfs_name.h:245
Per host statistics.
Definition: pfs_host.h:63
PFS_host_key m_key
Definition: pfs_host.h:114
pfs_lock m_lock
Definition: pfs_host.h:113
PFS_memory_shared_stat * write_instr_class_memory_stats()
Definition: pfs_host.h:104
PFS_memory_shared_stat * m_instr_class_memory_stats
Per host memory aggregated statistics.
Definition: pfs_host.h:139
void inc_refcount()
Definition: pfs_host.h:69
ulonglong m_max_total_memory
Definition: pfs_host.h:128
void dec_refcount()
Definition: pfs_host.h:71
void init_refcount()
Definition: pfs_host.h:65
void set_instr_class_memory_stats(PFS_memory_shared_stat *array)
Definition: pfs_host.h:92
ulonglong m_disconnected_count
Definition: pfs_host.h:126
const PFS_memory_shared_stat * read_instr_class_memory_stats() const
Definition: pfs_host.h:97
void reset_connections_stats()
Definition: pfs_host.h:116
int get_refcount()
Definition: pfs_host.h:67
std::atomic< int > m_refcount
Definition: pfs_host.h:131
ulonglong m_max_controlled_memory
Definition: pfs_host.h:127
Definition: pfs_stat.h:936
Definition: pfs_stat.h:882
Definition: pfs_stat.h:887
Instrumented thread implementation.
Definition: pfs_instr.h:374
A 'lock' protecting performance schema internal buffers.
Definition: pfs_lock.h:153
static void alive(server *s)
Definition: xcom_transport.cc:159