Commit c7744c6d authored by unknown's avatar unknown
Browse files

bug#12118 - ndb alter table data loss

  Split table version into 2 (major, minor)
  Impl. signaling to API when table has been altered
  Allow running transactions to use any minor number for transactions


mysql-test/r/ndb_alter_table.result:
  Allow running transactions to use old table definition when possible.
mysql-test/t/ndb_alter_table.test:
  Allow running transactions to use old table definition when possible.
ndb/include/kernel/BlockNumbers.h:
  remove GREP
ndb/include/kernel/GlobalSignalNumbers.h:
  Add ALTER_TABL_REP and API_BROADCAST_REP
ndb/include/kernel/kernel_types.h:
  table_version_major
ndb/include/kernel/signaldata/AlterTable.hpp:
  New error code for alter table during rolling upgrade
ndb/include/ndbapi/NdbDictionary.hpp:
  Add state on table object to represent an altered but still valid table object
ndb/src/common/debugger/BlockNames.cpp:
  remove GREP
ndb/src/common/util/version.c:
  Fix upgrades
ndb/src/kernel/SimBlockList.cpp:
  remove GREP
ndb/src/kernel/blocks/Makefile.am:
  remove GREP
ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
  remove GREP
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  Split tableSchemaVersion into 2 part
  24 bit real version
   8 bit for online alter table where old table definition is still usable
ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
  Check for same ndb versions
ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp:
  Update schema printer
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
  remove grep
ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
  1) Use table_ version_major when checking table version
  2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ
ndb/src/kernel/blocks/dbtc/Dbtc.hpp:
  1) Use table_ version_major when checking table version
  2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ
ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
  1) Use table_ version_major when checking table version
  2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ
ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp:
  remove GREP
ndb/src/kernel/blocks/qmgr/Qmgr.hpp:
  Add support for sending REP to ALL api nodes
ndb/src/kernel/blocks/qmgr/QmgrInit.cpp:
  Add support for sending REP to ALL api nodes
ndb/src/kernel/blocks/qmgr/QmgrMain.cpp:
  Add support for sending REP to ALL api nodes
ndb/src/kernel/blocks/suma/Suma.cpp:
  remove GREP
ndb/src/mgmsrv/MgmtSrvr.cpp:
  remove GREP
ndb/src/ndbapi/DictCache.cpp:
  Add support for alter_table_rep
    by setting status to Altered
  
  NOTE special handling of tables in state RETREIVING
ndb/src/ndbapi/DictCache.hpp:
  Add support for alter_table_rep
    by setting status to Altered
  
  NOTE special handling of tables in state RETREIVING
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Change alter table so that remove from global cache is used wo/ retreiving it from there first
    as ALTER_TABLE_REP might already have changed the table object...
ndb/src/ndbapi/TransporterFacade.cpp:
  Add support for ALTER_TABLE_REP
sql/ha_ndbcluster.cc:
  Allow running transactions to use tables in state ALTERED...but new transactions may not...
ndb/include/kernel/signaldata/ApiBroadcast.hpp:
  New BitKeeper file ``ndb/include/kernel/signaldata/ApiBroadcast.hpp''
parent c8cd901b
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -179,8 +179,24 @@ a b c
2	two	two
alter table t1 drop index c;
select * from t1 where b = 'two';
ERROR HY000: Table definition has changed, please retry transaction
a	b	c
2	two	two
select * from t1 where b = 'two';
a	b	c
2	two	two
drop table t1;
create table t3 (a int primary key) engine=ndbcluster;
begin;
insert into t3 values (1);
alter table t3 rename t4;
delete from t3;
insert into t3 values (1);
commit;
select * from t3;
ERROR HY000: Can't lock file (errno: 155)
select * from t4;
a
1
drop table t4;
show tables;
Tables_in_test
+25 −1
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ select * from t1 where b = 'two';
connection server1;
alter table t1 drop index c;
connection server2;
--error 1105
select * from t1 where b = 'two';
select * from t1 where b = 'two';
connection server1;
@@ -172,3 +171,28 @@ drop table t1;
#truncate table t2;
#select count(*) from t2;
#drop table t2;

connection server1;
create table t3 (a int primary key) engine=ndbcluster;

connection server2;
begin;
insert into t3 values (1);

connection server1;
alter table t3 rename t4;

connection server2;
# This should work as transaction is ongoing...
delete from t3;
insert into t3 values (1);
commit; 

# This should fail as its a new transaction
--error 1015
select * from t3;
select * from t4;
drop table t4;
show tables;
connection server1;
+1 −3
Original line number Diff line number Diff line
@@ -44,8 +44,7 @@
#define TRIX        0xFF
#define DBUTIL     0x100
#define SUMA       0x101
#define GREP       0x102
#define DBTUX      0x103
#define DBTUX      0x102

const BlockReference BACKUP_REF  = numberToRef(BACKUP, 0);
const BlockReference DBTC_REF    = numberToRef(DBTC, 0);
@@ -61,7 +60,6 @@ const BlockReference CMVMI_REF = numberToRef(CMVMI, 0);
const BlockReference TRIX_REF    = numberToRef(TRIX, 0);
const BlockReference DBUTIL_REF  = numberToRef(DBUTIL, 0);
const BlockReference SUMA_REF    = numberToRef(SUMA, 0);
const BlockReference GREP_REF    = numberToRef(GREP, 0);
const BlockReference DBTUX_REF   = numberToRef(DBTUX, 0);

const BlockNumber MIN_BLOCK_NO = BACKUP;
+2 −2
Original line number Diff line number Diff line
@@ -777,8 +777,8 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES;
/**
 * Grep signals
 */
#define GSN_GREP_SUB_CREATE_REQ         606
#define GSN_GREP_SUB_CREATE_REF         607
#define GSN_ALTER_TABLE_REP             606
#define GSN_API_BROADCAST_REP           607
#define GSN_GREP_SUB_CREATE_CONF        608
#define GSN_GREP_CREATE_REQ             609
#define GSN_GREP_CREATE_REF             610
+7 −0
Original line number Diff line number Diff line
@@ -36,6 +36,13 @@ enum Operation_t {
#endif
};

inline
Uint32 
table_version_major(Uint32 ver)
{
  return ver & 0x00FFFFFF;
}

#endif


Loading