new apply_status table test adoption

new apply_status table ndb_restore adoption
parent afdbe36a
...@@ -45,8 +45,8 @@ SYSTEM_VALUES_ID VALUE ...@@ -45,8 +45,8 @@ SYSTEM_VALUES_ID VALUE
0 2039 0 2039
1 3 1 3
SELECT * FROM mysql.ndb_apply_status WHERE server_id=0; SELECT * FROM mysql.ndb_apply_status WHERE server_id=0;
server_id epoch server_id epoch log_name start_pos end_pos
0 151 0 151 0 0
TRUNCATE GL; TRUNCATE GL;
TRUNCATE ACCOUNT; TRUNCATE ACCOUNT;
TRUNCATE TRANSACTION; TRUNCATE TRANSACTION;
...@@ -99,6 +99,6 @@ SYSTEM_VALUES_ID VALUE ...@@ -99,6 +99,6 @@ SYSTEM_VALUES_ID VALUE
0 2297 0 2297
1 5 1 5
SELECT * FROM mysql.ndb_apply_status WHERE server_id=0; SELECT * FROM mysql.ndb_apply_status WHERE server_id=0;
server_id epoch server_id epoch log_name start_pos end_pos
0 331 0 331 0 0
DROP DATABASE BANK; DROP DATABASE BANK;
...@@ -87,12 +87,12 @@ master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F ...@@ -87,12 +87,12 @@ master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000002 # Query 1 # COMMIT master-bin.000002 # Query 1 # COMMIT
show binary logs; show binary logs;
Log_name File_size Log_name File_size
master-bin.000001 1702 master-bin.000001 1740
master-bin.000002 593 master-bin.000002 612
start slave; start slave;
show binary logs; show binary logs;
Log_name File_size Log_name File_size
slave-bin.000001 1797 slave-bin.000001 1835
slave-bin.000002 198 slave-bin.000002 198
show binlog events in 'slave-bin.000001' from 4; show binlog events in 'slave-bin.000001' from 4;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
...@@ -126,7 +126,7 @@ slave-bin.000002 # Write_rows 2 # table_id: # flags: STMT_END_F ...@@ -126,7 +126,7 @@ slave-bin.000002 # Write_rows 2 # table_id: # flags: STMT_END_F
slave-bin.000002 # Query 2 # COMMIT slave-bin.000002 # Query 2 # COMMIT
show slave status; show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 593 # # master-bin.000002 Yes Yes # 0 0 593 # None 0 No # # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 612 # # master-bin.000002 Yes Yes # 0 0 612 # None 0 No #
show binlog events in 'slave-bin.000005' from 4; show binlog events in 'slave-bin.000005' from 4;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
DROP TABLE t1; DROP TABLE t1;
......
...@@ -33,12 +33,12 @@ master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 ...@@ -33,12 +33,12 @@ master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 219 Query 1 283 BEGIN master-bin.000001 219 Query 1 283 BEGIN
master-bin.000001 283 Table_map 1 40 table_id: # (test.t1) master-bin.000001 283 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 323 Table_map 1 95 table_id: # (mysql.ndb_apply_status) master-bin.000001 323 Table_map 1 98 table_id: # (mysql.ndb_apply_status)
master-bin.000001 378 Write_rows 1 137 table_id: # master-bin.000001 381 Write_rows 1 156 table_id: #
master-bin.000001 420 Write_rows 1 184 table_id: # flags: STMT_END_F master-bin.000001 439 Write_rows 1 203 table_id: # flags: STMT_END_F
master-bin.000001 467 Query 1 532 COMMIT master-bin.000001 486 Query 1 551 COMMIT
master-bin.000001 532 Query 1 612 use `test`; TRUNCATE TABLE t1 master-bin.000001 551 Query 1 631 use `test`; TRUNCATE TABLE t1
master-bin.000001 612 Query 1 688 use `test`; DROP TABLE t1 master-bin.000001 631 Query 1 707 use `test`; DROP TABLE t1
**** On Master **** **** On Master ****
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2); INSERT INTO t1 VALUES (1,1), (2,2);
...@@ -69,23 +69,23 @@ master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 ...@@ -69,23 +69,23 @@ master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 219 Query 1 283 BEGIN master-bin.000001 219 Query 1 283 BEGIN
master-bin.000001 283 Table_map 1 40 table_id: # (test.t1) master-bin.000001 283 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 323 Table_map 1 95 table_id: # (mysql.ndb_apply_status) master-bin.000001 323 Table_map 1 98 table_id: # (mysql.ndb_apply_status)
master-bin.000001 378 Write_rows 1 137 table_id: # master-bin.000001 381 Write_rows 1 156 table_id: #
master-bin.000001 420 Write_rows 1 184 table_id: # flags: STMT_END_F master-bin.000001 439 Write_rows 1 203 table_id: # flags: STMT_END_F
master-bin.000001 467 Query 1 532 COMMIT master-bin.000001 486 Query 1 551 COMMIT
master-bin.000001 532 Query 1 612 use `test`; TRUNCATE TABLE t1 master-bin.000001 551 Query 1 631 use `test`; TRUNCATE TABLE t1
master-bin.000001 612 Query 1 688 use `test`; DROP TABLE t1 master-bin.000001 631 Query 1 707 use `test`; DROP TABLE t1
master-bin.000001 688 Query 1 805 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB master-bin.000001 707 Query 1 824 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 805 Query 1 869 BEGIN master-bin.000001 824 Query 1 888 BEGIN
master-bin.000001 869 Table_map 1 40 table_id: # (test.t1) master-bin.000001 888 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 909 Table_map 1 95 table_id: # (mysql.ndb_apply_status) master-bin.000001 928 Table_map 1 98 table_id: # (mysql.ndb_apply_status)
master-bin.000001 964 Write_rows 1 137 table_id: # master-bin.000001 986 Write_rows 1 156 table_id: #
master-bin.000001 1006 Write_rows 1 184 table_id: # flags: STMT_END_F master-bin.000001 1044 Write_rows 1 203 table_id: # flags: STMT_END_F
master-bin.000001 1053 Query 1 1118 COMMIT master-bin.000001 1091 Query 1 1156 COMMIT
master-bin.000001 1118 Query 1 1182 BEGIN master-bin.000001 1156 Query 1 1220 BEGIN
master-bin.000001 1182 Table_map 1 40 table_id: # (test.t1) master-bin.000001 1220 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 1222 Table_map 1 95 table_id: # (mysql.ndb_apply_status) master-bin.000001 1260 Table_map 1 98 table_id: # (mysql.ndb_apply_status)
master-bin.000001 1277 Write_rows 1 137 table_id: # master-bin.000001 1318 Write_rows 1 156 table_id: #
master-bin.000001 1319 Delete_rows 1 176 table_id: # flags: STMT_END_F master-bin.000001 1376 Delete_rows 1 195 table_id: # flags: STMT_END_F
master-bin.000001 1358 Query 1 1423 COMMIT master-bin.000001 1415 Query 1 1480 COMMIT
master-bin.000001 1423 Query 1 1499 use `test`; DROP TABLE t1 master-bin.000001 1480 Query 1 1556 use `test`; DROP TABLE t1
...@@ -617,6 +617,7 @@ BackupRestore::update_apply_status(const RestoreMetaData &metaData) ...@@ -617,6 +617,7 @@ BackupRestore::update_apply_status(const RestoreMetaData &metaData)
return true; return true;
bool result= false; bool result= false;
unsigned apply_table_format= 0;
m_ndb->setDatabaseName(NDB_REP_DB); m_ndb->setDatabaseName(NDB_REP_DB);
m_ndb->setSchemaName("def"); m_ndb->setSchemaName("def");
...@@ -629,8 +630,33 @@ BackupRestore::update_apply_status(const RestoreMetaData &metaData) ...@@ -629,8 +630,33 @@ BackupRestore::update_apply_status(const RestoreMetaData &metaData)
<< dict->getNdbError() << endl; << dict->getNdbError() << endl;
return false; return false;
} }
if
(ndbtab->getColumn(0)->getType() == NdbDictionary::Column::Unsigned &&
ndbtab->getColumn(1)->getType() == NdbDictionary::Column::Bigunsigned)
{
if (ndbtab->getNoOfColumns() == 2)
{
apply_table_format= 1;
}
else if
(ndbtab->getColumn(2)->getType() == NdbDictionary::Column::Varchar &&
ndbtab->getColumn(3)->getType() == NdbDictionary::Column::Bigunsigned &&
ndbtab->getColumn(4)->getType() == NdbDictionary::Column::Bigunsigned)
{
apply_table_format= 2;
}
}
if (apply_table_format == 0)
{
err << Ndb_apply_table << " has wrong format\n";
return false;
}
Uint32 server_id= 0; Uint32 server_id= 0;
Uint64 epoch= metaData.getStopGCP(); Uint64 epoch= metaData.getStopGCP();
Uint64 zero= 0;
char empty_string[1];
empty_string[0]= 0;
NdbTransaction * trans= m_ndb->startTransaction(); NdbTransaction * trans= m_ndb->startTransaction();
if (!trans) if (!trans)
{ {
...@@ -653,6 +679,15 @@ BackupRestore::update_apply_status(const RestoreMetaData &metaData) ...@@ -653,6 +679,15 @@ BackupRestore::update_apply_status(const RestoreMetaData &metaData)
<< op->getNdbError() << endl; << op->getNdbError() << endl;
goto err; goto err;
} }
if ((apply_table_format == 2) &&
(op->setValue(2u, (const char *)&empty_string, 1) ||
op->setValue(3u, (const char *)&zero, sizeof(zero)) ||
op->setValue(4u, (const char *)&zero, sizeof(zero))))
{
err << Ndb_apply_table << ": "
<< op->getNdbError() << endl;
goto err;
}
if (trans->execute(NdbTransaction::Commit)) if (trans->execute(NdbTransaction::Commit))
{ {
err << Ndb_apply_table << ": " err << Ndb_apply_table << ": "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment