Skip to content

Commit ad281b3

Browse files
dtcpatriciodahlerlend
authored andcommitted
Bug#36313793 Remove double unpack of ndb_apply_status event [1/3]
In preparation of Bug#36313793 ndb-log-apply-status fails to work with no replicated changes in BI. Handling the ndb_apply_status updates start with unpacking the whole record just to have access to two variables for assertment. The record is unpacked once again when handling the I/U/D. This patch removes the double unpack of the ndb_apply_status table event, extracting these two values directly. Adds some DBUG_PRINTS to track the handling of ndb_apply_status updates. Change-Id: I3f280232808bac27cfec13a6df8c710a48599b21
1 parent 4869d45 commit ad281b3

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

storage/ndb/plugin/ha_ndbcluster_binlog.cc

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6269,27 +6269,18 @@ int Ndb_binlog_thread::handle_data_event(const NdbEventOperation *pOp,
62696269
const NDBEVENT::TableEvent event_type = pOp->getEventType();
62706270
if (event_type == NDBEVENT::TE_INSERT ||
62716271
event_type == NDBEVENT::TE_UPDATE) {
6272-
// Initialize "unused_bitmap" which is an output parameter from
6273-
// handle_data_unpack_record, afterwards it's not used which means it
6274-
// need not be initialized with anything useful
6275-
MY_BITMAP unused_bitmap;
6276-
Ndb_bitmap_buf<NDB_MAX_ATTRIBUTES_IN_TABLE> unused_bitbuf;
6277-
ndb_bitmap_init(&unused_bitmap, unused_bitbuf, table->s->fields);
6278-
6279-
// Unpack data event on mysql.ndb_apply_status to get orig_server_id
6280-
// and orig_epoch
6281-
handle_data_unpack_record(table, event_data->ndb_value[0].get(),
6282-
&unused_bitmap, table->record[0]);
6283-
6284-
// Assume that mysql.ndb_apply_status table has two fields (which should
6285-
// thus have been unpacked)
6286-
ndbcluster::ndbrequire(table->field[0] != nullptr &&
6287-
table->field[1] != nullptr);
6288-
6289-
const Uint32 orig_server_id =
6290-
(Uint32) static_cast<Field_long *>(table->field[0])->val_int();
6291-
const Uint64 orig_epoch =
6292-
static_cast<Field_longlong *>(table->field[1])->val_int();
6272+
const Uint32 orig_server_id = event_data->unpack_uint32(0);
6273+
const Uint64 orig_epoch = event_data->unpack_uint64(1);
6274+
6275+
DBUG_PRINT("info", ("ndb_apply_status from logging_server_id: %d",
6276+
logging_server_id));
6277+
DBUG_PRINT("info", (" orig_server_id: %u", orig_server_id));
6278+
DBUG_PRINT("info", (" orig_epoch: %llu", orig_epoch));
6279+
DBUG_PRINT("info",
6280+
(" log_name: '%s'", event_data->unpack_string(2) + 1));
6281+
6282+
DBUG_PRINT("info", (" start_pos: %u", event_data->unpack_uint32(3)));
6283+
DBUG_PRINT("info", (" end_pos: %u", event_data->unpack_uint32(4)));
62936284

62946285
if (opt_ndb_log_apply_status) {
62956286
/*

storage/ndb/plugin/ndb_event_data.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ uint32 Ndb_event_data::unpack_uint32(unsigned attr_id) const {
267267
return ndb_value[0][attr_id].rec->u_32_value();
268268
}
269269

270+
uint64 Ndb_event_data::unpack_uint64(unsigned attr_id) const {
271+
return ndb_value[0][attr_id].rec->u_64_value();
272+
}
273+
270274
const char *Ndb_event_data::unpack_string(unsigned attr_id) const {
271275
return ndb_value[0][attr_id].rec->aRef();
272276
}

storage/ndb/plugin/ndb_event_data.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class Ndb_event_data {
121121

122122
// Read uint32 value directly from NdbRecAttr in received event
123123
uint32 unpack_uint32(unsigned attr_id) const;
124+
// Read uint64 value directly from NdbRecAttr in received event
125+
uint64 unpack_uint64(unsigned attr_id) const;
124126
// Read string value directly from NdbRecAttr in received event
125127
const char *unpack_string(unsigned attr_id) const;
126128

storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ NdbEventOperationImpl *NdbEventBuffer::getEpochEventOperations(
17321732
event_types = gci_op.event_types;
17331733
cumulative_any_value = gci_op.cumulative_any_value;
17341734
filtered_any_value = gci_op.filtered_any_value;
1735-
DBUG_PRINT("info", ("gci: %u op: %p event_types: 0x%lx"
1735+
DBUG_PRINT("info", ("gci: %u op: %p event_types: 0x%lx "
17361736
"cumulative_any_value: 0x%lx "
17371737
"reference: '0x%x %s'",
17381738
(unsigned)epoch->m_gci.getGCI(), gci_op.op,

0 commit comments

Comments
 (0)