Skip to content

Commit 7ba4d18

Browse files
committed
Bug#36579842 Backport ndbinfo.transporter_details enhancements to 8.0
Part 1/2, backport of commit : 7357e3e5decb7128bf703e8b30c31b75c235f4c9 WL#7662 Sendbuffer usage monitoring The NdbInfo transporter_details table is extended with columns giving per transporter sendbuffer usage information for SendBuffers in the data nodes : New columns are : - sendbuffer_used_bytes Number of bytes of signal data stored in SendBuffer pending send using this transporter. - sendbuffer_max_used_bytes Maximum number of bytes of signal data stored in SendBuffer pending send since most recent transporter connect - sendbuffer_alloc_bytes Number of bytes of SendBuffer allocated for storing signal data pending send using this transporter. SendBuffer is allocated in pages which may not be fully utilised - sendbuffer_max_alloc_bytes Maximum number of bytes of SendBuffer allocated for pending sends since most recent transporter connect The values are sampled before and after sending. Change-Id: I7ef4f6f9dfec982b365c6345311c62d163ccc20e
1 parent f4c6406 commit 7ba4d18

File tree

11 files changed

+226
-70
lines changed

11 files changed

+226
-70
lines changed

mysql-test/suite/ndb/r/ndbinfo_plans.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ index_columns 20 80
6262
ndb$acc_operations 15 64
6363
ndb$backup_id 1 20
6464
ndb$blocks 29 20
65-
ndb$columns 550 44
65+
ndb$columns 554 44
6666
ndb$config_nodes 34 28
6767
ndb$config_params 167 120
6868
ndb$config_values 330 24
@@ -107,7 +107,7 @@ ndb$threadblocks 124 16
107107
ndb$threads 26 40
108108
ndb$threadstat 22 144
109109
ndb$transactions 5 44
110-
ndb$transporter_details 32 76
110+
ndb$transporter_details 32 108
111111
ndb$transporters 32 64
112112

113113
## List the tables where estimated size equals actual size.

storage/ndb/include/transporter/TransporterRegistry.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ class TransporterRegistry {
430430
*/
431431
Uint32 get_connect_count(TrpId trpId) const;
432432

433+
/**
434+
* Update send buffer allocated and used bytes for given transporter
435+
*/
436+
void update_send_buffer_usage(TrpId trpId, Uint64 allocBytes,
437+
Uint64 usedBytes);
438+
433439
/**
434440
* Set or clear overloaded bit.
435441
* Query if any overloaded bit is set.
@@ -454,6 +460,14 @@ class TransporterRegistry {
454460
*/
455461
Uint32 get_slowdown_count(NodeId nodeId) const;
456462

463+
/**
464+
* Get SendBuffer alloc + usage info
465+
*/
466+
Uint64 get_send_buffer_alloc_bytes(TrpId trpId) const;
467+
Uint64 get_send_buffer_used_bytes(TrpId trpId) const;
468+
Uint64 get_send_buffer_max_alloc_bytes(TrpId trpId) const;
469+
Uint64 get_send_buffer_max_used_bytes(TrpId trpId) const;
470+
457471
/**
458472
* prepareSend
459473
*

storage/ndb/plugin/ha_ndbinfo_sql.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,9 @@ static struct view {
660660
" END AS status, "
661661
" remote_address, bytes_sent, bytes_received, "
662662
" connect_count, "
663-
" overloaded, overload_count, slowdown, slowdown_count, encrypted "
663+
" overloaded, overload_count, slowdown, slowdown_count, encrypted, "
664+
" sendbuffer_used_bytes, sendbuffer_max_used_bytes, "
665+
" sendbuffer_alloc_bytes, sendbuffer_max_alloc_bytes "
664666
"FROM `ndbinfo`.`ndb$transporter_details`"},
665667
{"ndbinfo", "transporters",
666668
"SELECT node_id, remote_node_id, "

storage/ndb/src/common/debugger/NdbinfoTables.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ DECLARE_NDBINFO_TABLE(POOLS, 14) = {
105105
{"resource_id", Ndbinfo::Number, ""},
106106
{"type_id", Ndbinfo::Number, "Record type id within resource"}}};
107107

108-
DECLARE_NDBINFO_TABLE(TRANSPORTER_DETAILS, 14) = {
109-
{"transporter_details", 14, 0,
108+
DECLARE_NDBINFO_TABLE(TRANSPORTER_DETAILS, 18) = {
109+
{"transporter_details", 18, 0,
110110
[](const Ndbinfo::Counts &counts) {
111111
return (counts.data_nodes) * (counts.all_nodes - 1);
112112
},
@@ -131,7 +131,15 @@ DECLARE_NDBINFO_TABLE(TRANSPORTER_DETAILS, 14) = {
131131
{"slowdown", Ndbinfo::Number, "Is link requesting slowdown"},
132132
{"slowdown_count", Ndbinfo::Number,
133133
"Number of slowdown onsets since connect"},
134-
{"encrypted", Ndbinfo::Number, "Is link using TLS encryption"}}};
134+
{"encrypted", Ndbinfo::Number, "Is link using TLS encryption"},
135+
136+
{"sendbuffer_used_bytes", Ndbinfo::Number64, "SendBuffer bytes in use"},
137+
{"sendbuffer_max_used_bytes", Ndbinfo::Number64,
138+
"SendBuffer historical max bytes in use"},
139+
{"sendbuffer_alloc_bytes", Ndbinfo::Number64,
140+
"SendBuffer bytes allocated"},
141+
{"sendbuffer_max_alloc_bytes", Ndbinfo::Number64,
142+
"SendBuffer historical max bytes allocated"}}};
135143

136144
DECLARE_NDBINFO_TABLE(TRANSPORTERS, 11) = {
137145
{"transporters", 11, 0,

storage/ndb/src/common/transporter/Transporter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Transporter::Transporter(TransporterRegistry &t_reg, TrpId transporter_index,
8383
m_connect_count(0),
8484
m_overload_count(0),
8585
m_slowdown_count(0),
86+
m_send_buffer_alloc_bytes(0),
87+
m_send_buffer_max_alloc_bytes(0),
88+
m_send_buffer_used_bytes(0),
89+
m_send_buffer_max_used_bytes(0),
8690
isMgmConnection(_isMgmConnection),
8791
m_connected(false),
8892
m_type(_type),
@@ -463,6 +467,10 @@ void Transporter::resetCounters() {
463467
m_bytes_received = 0;
464468
m_overload_count = 0;
465469
m_slowdown_count = 0;
470+
m_send_buffer_alloc_bytes = 0;
471+
m_send_buffer_max_alloc_bytes = 0;
472+
m_send_buffer_used_bytes = 0;
473+
m_send_buffer_max_used_bytes = 0;
466474
}
467475

468476
void Transporter::checksum_state::dumpBadChecksumInfo(

storage/ndb/src/common/transporter/Transporter.hpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,23 @@ class Transporter {
151151
used >= m_slowdown_limit);
152152
}
153153

154+
/**
155+
* Update ndbinfo statistics about sendbuffer bytes allocated and
156+
* used by transporter.
157+
* Note that allocated bytes may be sparsely populated pages,
158+
* resulting in an overallocation of pages as well.
159+
* We expect the buffers soon to be packed in such cases.
160+
*/
161+
void update_send_buffer_usage(Uint64 allocBytes, Uint64 usedBytes) {
162+
m_send_buffer_alloc_bytes = allocBytes;
163+
if (allocBytes > m_send_buffer_max_alloc_bytes)
164+
m_send_buffer_max_alloc_bytes = allocBytes;
165+
166+
m_send_buffer_used_bytes = usedBytes;
167+
if (usedBytes > m_send_buffer_max_used_bytes)
168+
m_send_buffer_max_used_bytes = usedBytes;
169+
}
170+
154171
virtual bool doSend(bool need_wakeup = true) = 0;
155172

156173
/* Get the configured maximum send buffer usage. */
@@ -171,6 +188,12 @@ class Transporter {
171188

172189
TransporterType getTransporterType() const;
173190

191+
Uint64 get_alloc_bytes() const { return m_send_buffer_alloc_bytes; }
192+
Uint64 get_max_alloc_bytes() const { return m_send_buffer_max_alloc_bytes; }
193+
194+
Uint64 get_used_bytes() const { return m_send_buffer_used_bytes; }
195+
Uint64 get_max_used_bytes() const { return m_send_buffer_max_used_bytes; }
196+
174197
protected:
175198
Transporter(TransporterRegistry &, TrpId transporter_index, TransporterType,
176199
const char *lHostName, const char *rHostName, int s_port,
@@ -228,13 +251,20 @@ class Transporter {
228251
/* Overload limit, as configured with the OverloadLimit config parameter. */
229252
Uint32 m_overload_limit;
230253
Uint32 m_slowdown_limit;
231-
void resetCounters();
232254
Uint64 m_bytes_sent;
233255
Uint64 m_bytes_received;
234256
Uint32 m_connect_count;
235257
Uint32 m_overload_count;
236258
Uint32 m_slowdown_count;
237259

260+
Uint64 m_send_buffer_alloc_bytes;
261+
Uint64 m_send_buffer_max_alloc_bytes; // Historic max use
262+
263+
Uint64 m_send_buffer_used_bytes;
264+
Uint64 m_send_buffer_max_used_bytes; // Historic max use
265+
266+
void resetCounters();
267+
238268
// Sending/Receiving socket used by both client and server
239269
NdbSocket theSocket;
240270

@@ -361,9 +391,14 @@ inline Uint32 Transporter::fetch_send_iovec_data(struct iovec dst[],
361391
}
362392

363393
inline void Transporter::iovec_data_sent(int nBytesSent) {
364-
Uint32 used_bytes =
394+
Uint32 remaining_bytes =
365395
get_callback_obj()->bytes_sent(m_transporter_index, nBytesSent);
366-
update_status_overloaded(used_bytes);
396+
update_status_overloaded(remaining_bytes);
397+
398+
if (remaining_bytes == 0) {
399+
m_send_buffer_alloc_bytes = 0;
400+
m_send_buffer_used_bytes = 0;
401+
}
367402
}
368403

369404
inline bool Transporter::checksum_state::compute(const void *buf, size_t len) {

storage/ndb/src/common/transporter/TransporterRegistry.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,6 +3283,18 @@ void TransporterRegistry::inc_overload_count(NodeId nodeId) {
32833283
theNodeIdTransporters[nodeId]->inc_overload_count();
32843284
}
32853285

3286+
/**
3287+
* TR need to inform Transporter about how much pending buffered
3288+
* send data there is.
3289+
*/
3290+
void TransporterRegistry::update_send_buffer_usage(TrpId trpId,
3291+
Uint64 allocBytes,
3292+
Uint64 usedBytes) {
3293+
assert(trpId < maxTransporters);
3294+
assert(allTransporters[trpId] != nullptr);
3295+
allTransporters[trpId]->update_send_buffer_usage(allocBytes, usedBytes);
3296+
}
3297+
32863298
void TransporterRegistry::inc_slowdown_count(NodeId nodeId) {
32873299
assert(nodeId < MAX_NODES);
32883300
assert(theNodeIdTransporters[nodeId] != nullptr);
@@ -3307,6 +3319,30 @@ Uint32 TransporterRegistry::get_connect_count(TrpId trpId) const {
33073319
return allTransporters[trpId]->get_connect_count();
33083320
}
33093321

3322+
Uint64 TransporterRegistry::get_send_buffer_alloc_bytes(TrpId trpId) const {
3323+
assert(trpId < MAX_NTRANSPORTERS);
3324+
assert(allTransporters[trpId] != nullptr);
3325+
return allTransporters[trpId]->get_alloc_bytes();
3326+
}
3327+
3328+
Uint64 TransporterRegistry::get_send_buffer_max_alloc_bytes(TrpId trpId) const {
3329+
assert(trpId < MAX_NTRANSPORTERS);
3330+
assert(allTransporters[trpId] != nullptr);
3331+
return allTransporters[trpId]->get_max_alloc_bytes();
3332+
}
3333+
3334+
Uint64 TransporterRegistry::get_send_buffer_used_bytes(TrpId trpId) const {
3335+
assert(trpId < MAX_NTRANSPORTERS);
3336+
assert(allTransporters[trpId] != nullptr);
3337+
return allTransporters[trpId]->get_used_bytes();
3338+
}
3339+
3340+
Uint64 TransporterRegistry::get_send_buffer_max_used_bytes(TrpId trpId) const {
3341+
assert(trpId < MAX_NTRANSPORTERS);
3342+
assert(allTransporters[trpId] != nullptr);
3343+
return allTransporters[trpId]->get_max_used_bytes();
3344+
}
3345+
33103346
void TransporterRegistry::get_trps_for_node(NodeId nodeId, TrpId *trp_ids,
33113347
Uint32 &num_ids,
33123348
Uint32 max_size) const {

storage/ndb/src/kernel/blocks/trpman.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ void Trpman::execDBINFO_SCANREQ(Signal *signal) {
503503

504504
/* Connect count, overload and slowdown states */
505505
row.write_uint32(globalTransporterRegistry.get_connect_count(trpId));
506-
507506
/* FIXME: overload & slowdown is still pr NodeId */
508507
row.write_uint32(
509508
globalTransporterRegistry.get_status_overloaded().get(nodeId));
@@ -515,6 +514,16 @@ void Trpman::execDBINFO_SCANREQ(Signal *signal) {
515514
/* TLS, not available until 8.3 -> is_encrypted=false*/
516515
row.write_uint32(false);
517516

517+
/* Send buffer bytes/pages usage */
518+
row.write_uint64(
519+
globalTransporterRegistry.get_send_buffer_used_bytes(trpId));
520+
row.write_uint64(
521+
globalTransporterRegistry.get_send_buffer_max_used_bytes(trpId));
522+
row.write_uint64(
523+
globalTransporterRegistry.get_send_buffer_alloc_bytes(trpId));
524+
row.write_uint64(
525+
globalTransporterRegistry.get_send_buffer_max_alloc_bytes(trpId));
526+
518527
ndbinfo_send_row(signal, req, row, rl);
519528
trpId++;
520529
if (rl.need_break(req)) {

storage/ndb/src/kernel/vm/TransporterCallback.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,14 +647,23 @@ Uint32 TransporterCallbackKernelNonMT::get_bytes_to_send_iovec(
647647

648648
Uint32 count = 0;
649649
SendBufferPage *page = b->m_first_page;
650-
while (page != NULL && count < max) {
650+
while (page != nullptr && count < max) {
651651
dst[count].iov_base = page->m_data + page->m_start;
652652
dst[count].iov_len = page->m_bytes;
653653
assert(page->m_start + page->m_bytes <= page->max_data_bytes());
654654
page = page->m_next;
655655
count++;
656656
}
657657

658+
// For send_buffer_usage we count pages beyond 'max' as well
659+
Uint32 pages = count;
660+
while (unlikely(page != nullptr)) {
661+
page = page->m_next;
662+
pages++;
663+
}
664+
globalTransporterRegistry.update_send_buffer_usage(
665+
trp_id, Uint64(pages) * SendBufferPage::PGSIZE, b->m_used_bytes);
666+
658667
return count;
659668
}
660669

0 commit comments

Comments
 (0)