Skip to content

Commit a045df8

Browse files
committed
BUG#34667384 Report flags incorrect for opened event
When opening a NdbDictionary::Event from NDB the report option flags are not sent to the NdbApi, this causes the Event::getReport() function to always indicate that only updated columns would be reported for NdbDictionary::Event's. This problem makes it impossible to use the NdbApi for checking how an Event is configured in NDB. Furthermore the Event::getReport() function is documented as returning only one value while it actually returns a value consisting of several 'EventReport' flags. Due to this the `ndbinfo.reporting` column is using an ENUM value which also always shows the same value due to first problem. Fix by extending the CreateEvntConf signal with an additional data field to send the report flags and translate them from CreateEventReq::EventFlags to 'EventReport' flags as used in the NdbApi. Also change the `ndbinfo.reporting` column to use a SET to describe the different report flags for each event in NDB, this means that were the `reporting` column preivosly only returned one value it will now show more than one. The complete functionality is tested by showing how events for the well known tables of ndb_ddl suite are configured. Add signal data printers for CreateEvntReq, CreateEvntConf and CreateEvntRef. Also improve functionality for EventDurability: * Change Event::getDurability() to always return correctly that Event is created as permanent (ED_PERMANENT) which is the only supported value. * Add function comment describing that Event::setDurability() has no effect, event will alwyas be created as permanent. Change-Id: I91a47331ffcb74c39b979e8c44c7e1f167ac1c35
1 parent 2cf9f59 commit a045df8

File tree

17 files changed

+213
-98
lines changed

17 files changed

+213
-98
lines changed

mysql-test/suite/ndb_ddl/check_event_for_table.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ let $found_event = `SELECT count(*) FROM ndbinfo.events
3838
if ($found_event)
3939
{
4040
echo Found event for '$check_event_dbname.$check_event_tabname';
41+
42+
#
43+
# Check how report options for the event is configured. Use the 'reporting'
44+
# column of ndbinfo.events which is a SET that correspond to the flags
45+
# describing what should be reported
46+
let $reporting = `SELECT reporting FROM ndbinfo.events
47+
WHERE name = '$expected_event_name'`;
48+
echo Report flags: '$reporting';
49+
4150
}
4251
if (!$found_event)
4352
{
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
Found event for 'mysql.ndb_apply_status'
2+
Report flags: 'updated,DDL'
23
Found event for 'mysql.ndb_schema'
4+
Report flags: 'all,subscribe,DDL'
35
Found event for 'mysql.ndb_schema_result'
6+
Report flags: 'all,DDL'
47
Found event for 'ndb_ddl_test.t1'
8+
Report flags: 'updated,DDL'
59
Found event for 'ndb_ddl_test.t2'
10+
Report flags: 'updated,DDL'
611
Found event for 'ndb_ddl_test.t3'
12+
Report flags: 'updated,DDL'
713
Found event for 'ndb_ddl_test.t4'
14+
Report flags: 'updated,DDL'
815
Found event for 'ndb_ddl_test.t5'
16+
Report flags: 'updated,DDL'
917
Found event for 'ndb_ddl_test.t6'
18+
Report flags: 'all,DDL'
1019
Found event for 'ndb_ddl_test.t7'
20+
Report flags: 'updated,DDL'
1121
Found event for 'ndb_ddl_test.t8'
22+
Report flags: 'all,DDL'
1223
NOTE! t9 have hidden pk and blobs -> no event
1324
No event found for 'ndb_ddl_test.t9'

storage/ndb/include/kernel/signaldata/CreateEvnt.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ class CreateEvntConf {
339339

340340
public:
341341
// static constexpr Uint32 InternalLength = 3;
342-
static constexpr Uint32 SignalLength = 8+MAXNROFATTRIBUTESINWORDS_OLD;
342+
static constexpr Uint32 SignalLength_v8_0_31 = 8+MAXNROFATTRIBUTESINWORDS_OLD;
343+
static constexpr Uint32 SignalLength = 13;
343344

344345
union {
345346
Uint32 m_userRef; // user block reference
@@ -356,6 +357,7 @@ class CreateEvntConf {
356357
Uint32 m_eventType;
357358
Uint32 m_eventId;
358359
Uint32 m_eventKey;
360+
Uint32 m_reportFlags; // using CreateEvntReq::EventFlags
359361

360362
Uint32 getUserRef() const {
361363
return m_userRef;
@@ -411,6 +413,18 @@ class CreateEvntConf {
411413
void setEventKey(Uint32 val) {
412414
m_eventKey = val;
413415
}
416+
void setReportFlags(Uint32 val) {
417+
m_reportFlags = val;
418+
}
419+
Uint32 getReportAll() const {
420+
return m_reportFlags & CreateEvntReq::EF_REPORT_ALL;
421+
}
422+
Uint32 getReportSubscribe() const {
423+
return m_reportFlags & CreateEvntReq::EF_REPORT_SUBSCRIBE;
424+
}
425+
Uint32 getReportDDL() const {
426+
return (m_reportFlags & CreateEvntReq::EF_NO_REPORT_DDL) == 0;
427+
}
414428
};
415429

416430
/**

storage/ndb/include/kernel/signaldata/SignalData.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ GSN_PRINT_SIGNATURE(printISOLATE_ORD);
365365

366366
GSN_PRINT_SIGNATURE(printPROCESSINFO_REP);
367367
GSN_PRINT_SIGNATURE(printTRP_KEEP_ALIVE);
368+
GSN_PRINT_SIGNATURE(printCREATE_EVNT_CONF);
369+
GSN_PRINT_SIGNATURE(printCREATE_EVNT_REQ);
370+
GSN_PRINT_SIGNATURE(printCREATE_EVNT_REF);
368371

369372
/**
370373
Signal scope monitoring

storage/ndb/include/ndbapi/NdbDictionary.hpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,15 +1594,6 @@ class NdbDictionary {
15941594
ED_UNDEFINED
15951595
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
15961596
= 0
1597-
#endif
1598-
#if 0 // not supported
1599-
,ED_SESSION = 1,
1600-
// Only this API can use it
1601-
// and it's deleted after api has disconnected or ndb has restarted
1602-
1603-
ED_TEMPORARY = 2
1604-
// All API's can use it,
1605-
// But's its removed when ndb is restarted
16061597
#endif
16071598
,ED_PERMANENT ///< All API's can use it.
16081599
///< It's still defined after a cluster system restart
@@ -1681,20 +1672,33 @@ class NdbDictionary {
16811672
bool getTableEvent(const TableEvent te) const;
16821673
/**
16831674
* Set durability of the event
1675+
*
1676+
* @note This function has no effect
16841677
*/
16851678
void setDurability(EventDurability);
16861679
/**
16871680
* Get durability of the event
1681+
*
1682+
* @note This function always returns that event is permanent
16881683
*/
16891684
EventDurability getDurability() const;
16901685
/**
1691-
* Set report option of the event
1686+
* Set report options for the event
1687+
*
1688+
* @note The function accepts a value consisting of 'EventReport' flags
1689+
* describing what the event should report
1690+
*
16921691
*/
16931692
void setReport(EventReport);
1693+
void setReportOptions(Uint32 report_options);
16941694
/**
1695-
* Get report option of the event
1695+
* Get report options for the event
1696+
*
1697+
* @note The function returns a value consisting of 'EventReport' flags
1698+
* describing what the event is configured to report
16961699
*/
16971700
EventReport getReport() const;
1701+
Uint32 getReportOptions() const;
16981702
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
16991703
void addColumn(const Column &c);
17001704
#endif

storage/ndb/plugin/ha_ndbcluster_binlog.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,31 +5100,27 @@ int Ndb_binlog_client::create_event(Ndb *ndb,
51005100
my_event.addTableEvent(NDBEVENT::TE_ALL);
51015101
if (ndb_table_has_hidden_pk(ndbtab)) {
51025102
/* Hidden primary key, subscribe for all attributes */
5103-
my_event.setReport(
5104-
(NDBEVENT::EventReport)(NDBEVENT::ER_ALL | NDBEVENT::ER_DDL));
5103+
my_event.setReportOptions(NDBEVENT::ER_ALL | NDBEVENT::ER_DDL);
51055104
DBUG_PRINT("info", ("subscription all"));
51065105
} else {
51075106
if (Ndb_schema_dist_client::is_schema_dist_table(share->db,
51085107
share->table_name)) {
51095108
/**
51105109
* ER_SUBSCRIBE is only needed on schema distribution table
51115110
*/
5112-
my_event.setReport((NDBEVENT::EventReport)(
5113-
NDBEVENT::ER_ALL | NDBEVENT::ER_SUBSCRIBE | NDBEVENT::ER_DDL));
5111+
my_event.setReportOptions(NDBEVENT::ER_ALL | NDBEVENT::ER_SUBSCRIBE |
5112+
NDBEVENT::ER_DDL);
51145113
DBUG_PRINT("info", ("subscription all and subscribe"));
51155114
} else if (Ndb_schema_dist_client::is_schema_dist_result_table(
51165115
share->db, share->table_name)) {
5117-
my_event.setReport(
5118-
(NDBEVENT::EventReport)(NDBEVENT::ER_ALL | NDBEVENT::ER_DDL));
5116+
my_event.setReportOptions(NDBEVENT::ER_ALL | NDBEVENT::ER_DDL);
51195117
DBUG_PRINT("info", ("subscription all"));
51205118
} else {
51215119
if (share->get_binlog_full()) {
5122-
my_event.setReport(
5123-
(NDBEVENT::EventReport)(NDBEVENT::ER_ALL | NDBEVENT::ER_DDL));
5120+
my_event.setReportOptions(NDBEVENT::ER_ALL | NDBEVENT::ER_DDL);
51245121
DBUG_PRINT("info", ("subscription all"));
51255122
} else {
5126-
my_event.setReport(
5127-
(NDBEVENT::EventReport)(NDBEVENT::ER_UPDATED | NDBEVENT::ER_DDL));
5123+
my_event.setReportOptions(NDBEVENT::ER_UPDATED | NDBEVENT::ER_DDL);
51285124
DBUG_PRINT("info", ("subscription only updated"));
51295125
}
51305126
}

storage/ndb/plugin/ha_ndbinfo_sql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ static struct lookup {
729729
"event_id INT UNSIGNED NOT NULL PRIMARY KEY, "
730730
"name varchar(192) NOT NULL, "
731731
"table_id INT UNSIGNED NOT NULL, "
732-
"reporting enum('updated', 'all', 'subscribe', 'DDL') NOT NULL, "
732+
"reporting SET('updated', 'all', 'subscribe', 'DDL') NOT NULL, "
733733
"columns varchar(512) NOT NULL, "
734734
"table_event SET('INSERT','DELETE','UPDATE','SCAN','DROP','ALTER',"
735735
"'CREATE','GCP_COMPLETE','CLUSTER_FAILURE','STOP',"

storage/ndb/src/common/debugger/signaldata/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ADD_CONVENIENCE_LIBRARY(ndbsignaldata
3636
CntrStart.cpp
3737
ContinueB.cpp
3838
CopyGCI.cpp
39+
CreateEvnt.cpp
3940
CreateFK.cpp
4041
CreateFragmentation.cpp
4142
CreateIndx.cpp

storage/ndb/src/common/debugger/signaldata/CreateEvnt.cpp

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,103 @@
2525

2626
#include <signaldata/CreateEvnt.hpp>
2727

28-
bool printCREATE_EVNT_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo)
29-
{
30-
// const CreateEvntReq * const sig = (const CreateEvntReq *) theData;
28+
static void print_request_info(FILE *output,
29+
CreateEvntReq::RequestType req_type,
30+
Uint32 req_flags) {
31+
fprintf(output, " requestType: ");
32+
switch(req_type) {
33+
case CreateEvntReq::RT_UNDEFINED:
34+
fprintf(output, "'Undefined'");
35+
break;
36+
case CreateEvntReq::RT_USER_CREATE:
37+
fprintf(output, "'Create'");
38+
break;
39+
case CreateEvntReq::RT_USER_GET:
40+
fprintf(output, "'Get'");
41+
break;
42+
default:
43+
fprintf(output, "0x%08x", req_type);
44+
break;
45+
}
46+
if (req_flags) {
47+
fprintf(output, " flags: 0x%08x [", req_flags);
48+
if (req_flags & CreateEvntReq::RT_DICT_AFTER_GET)
49+
fprintf(output, "DICT_AFTER_GET ");
50+
fprintf(output, "]");
51+
}
52+
fprintf(output, "\n");
53+
}
54+
55+
bool printCREATE_EVNT_REQ(FILE *output, const Uint32 *theData, Uint32 len,
56+
Uint16) {
57+
if (len < CreateEvntReq::SignalLengthGet)
58+
{
59+
assert(false);
60+
return false;
61+
}
62+
63+
const CreateEvntReq * const sig = (const CreateEvntReq *) theData;
64+
fprintf(output, " senderRef: 0x%x", sig->senderRef);
65+
fprintf(output, " senderData: %u", sig->senderData);
66+
fprintf(output, "\n");
67+
print_request_info(output, sig->getRequestType(), sig->getRequestFlag());
68+
69+
if (len <= CreateEvntReq::SignalLengthGet)
70+
return true;
71+
72+
fprintf(output, " tableId: %u tableVersion: %u\n",
73+
sig->m_tableId, sig->m_tableVersion);
74+
// attrListBitmask;
75+
fprintf(output, " m_eventType: 0x%08x [eventType: %u, reportFlags: 0x%08x]\n",
76+
sig->m_eventType, sig->getEventType(), sig->getReportFlags());
77+
fprintf(output, " eventId: %u eventKey: %u\n", sig->m_eventId,
78+
sig->m_eventKey);
3179

3280
return false;
3381
}
3482

35-
bool printCREATE_EVNT_CONF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo)
36-
{
37-
// const CreateEvntConf * const sig = (const CreateEvntConf *) theData;
83+
bool printCREATE_EVNT_CONF(FILE *output, const Uint32 *theData, Uint32 len,
84+
Uint16) {
85+
if (len < CreateEvntConf::SignalLength_v8_0_31)
86+
{
87+
assert(false);
88+
return false;
89+
}
90+
91+
const CreateEvntConf * const sig = (const CreateEvntConf *) theData;
92+
fprintf(output, " senderRef: 0x%x", sig->senderRef);
93+
fprintf(output, " senderData: %u", sig->senderData);
94+
fprintf(output, "\n");
95+
print_request_info(output, sig->getRequestType(), 0);
96+
fprintf(output, " tableId: %u tableVersion: %u\n", sig->m_tableId, sig->m_tableVersion);
97+
// attrListBitmask;
98+
fprintf(output, " m_eventType: 0x%08x [eventType: %u]\n", sig->m_eventType, sig->getEventType());
99+
fprintf(output, " eventId: %u eventKey: %u\n", sig->m_eventId, sig->m_eventKey);
100+
if (len > CreateEvntConf::SignalLength_v8_0_31) {
101+
fprintf(output, " reportFlags: 0x%08x\n", sig->m_reportFlags);
102+
}
38103

39104
return false;
40105
}
41106

42-
bool printCREATE_EVNT_REF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo)
43-
{
44-
// const CreateEvntRef * const sig = (const CreateEvntRef *) theData;
107+
bool printCREATE_EVNT_REF(FILE *output, const Uint32 *theData, Uint32 len,
108+
Uint16) {
109+
if (len < CreateEvntRef::SignalLength)
110+
{
111+
assert(false);
112+
return false;
113+
}
114+
115+
const CreateEvntRef * const sig = (const CreateEvntRef *) theData;
116+
fprintf(output, " senderRef: 0x%x", sig->senderRef);
117+
fprintf(output, " senderData: %u", sig->senderData);
118+
fprintf(output, "\n");
119+
print_request_info(output, sig->getRequestType(), 0);
120+
fprintf(output, " errorCode: %u\n", sig->errorCode);
121+
fprintf(output, " errorLine: %u\n", sig->m_errorLine);
122+
fprintf(output, " errorRef: 0x%08x\n", sig->m_errorNode);
123+
if (len >= CreateEvntRef::SignalLength2)
124+
fprintf(output, " masterNodeId: %u\n", sig->m_masterNodeId);
45125

46126
return false;
47127
}

storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ SignalDataPrintFunctions[] = {
312312
,{ GSN_PROCESSINFO_REP, printPROCESSINFO_REP }
313313

314314
,{ GSN_TRP_KEEP_ALIVE, printTRP_KEEP_ALIVE }
315+
,{ GSN_CREATE_EVNT_REQ, printCREATE_EVNT_REQ}
316+
,{ GSN_CREATE_EVNT_CONF, printCREATE_EVNT_CONF}
317+
,{ GSN_CREATE_EVNT_REF, printCREATE_EVNT_REF}
315318
,{ 0, nullptr }
316319
};
317320

0 commit comments

Comments
 (0)