Commit 74aca9aa authored by unknown's avatar unknown
Browse files

ndb - bug#18781 bug#21017 bug#21050 : block index ops during NR + fix asserts


ndb/src/kernel/vm/DLHashTable2.hpp:
  add isEmpty for use in DICT
ndb/test/include/NDBT_Tables.hpp:
  getIndexes - return index cols of standard test table
ndb/test/src/NDBT_Tables.cpp:
  getIndexes - return index cols of standard test table
ndb/test/ndbapi/testDict.cpp:
  bug#21017: index create/drop during NR
ndb/include/kernel/signaldata/CreateIndx.hpp:
  add 711
ndb/include/kernel/signaldata/DropIndx.hpp:
  add 711
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  block index create/drop during NR.
  fix 2 ndbrequires by checking exact schema op types
ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
  block index create/drop during NR.
  fix 2 ndbrequires by checking exact schema op types
parent 5c8c2ab4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ public:
  enum ErrorCode {
    NoError = 0,
    Busy = 701,
    BusyWithNR = 711,
    NotMaster = 702,
    TriggerNotFound = 4238,
    TriggerExists = 4239,
+1 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ public:
    NoError = 0,
    InvalidIndexVersion = 241,
    Busy = 701,
    BusyWithNR = 711,
    NotMaster = 702,
    IndexNotFound = 4243,
    BadRequestType = 4247,
+36 −8
Original line number Diff line number Diff line
@@ -6520,9 +6520,18 @@ Dbdict::execCREATE_INDX_REQ(Signal* signal)
    }
    if (signal->getLength() == CreateIndxReq::SignalLength) {
      jam();
      CreateIndxRef::ErrorCode tmperr = CreateIndxRef::NoError;
      if (getOwnNodeId() != c_masterNodeId) {
        jam();
	
        tmperr = CreateIndxRef::NotMaster;
      } else if (c_blockState == BS_NODE_RESTART) {
        jam();
        tmperr = CreateIndxRef::BusyWithNR;
      } else if (c_blockState != BS_IDLE) {
        jam();
        tmperr = CreateIndxRef::Busy;
      }
      if (tmperr != CreateIndxRef::NoError) {
	releaseSections(signal);
	OpCreateIndex opBusy;
	opPtr.p = &opBusy;
@@ -6530,13 +6539,12 @@ Dbdict::execCREATE_INDX_REQ(Signal* signal)
	opPtr.p->m_isMaster = (senderRef == reference());
	opPtr.p->key = 0;
	opPtr.p->m_requestType = CreateIndxReq::RT_DICT_PREPARE;
	opPtr.p->m_errorCode = CreateIndxRef::NotMaster;
	opPtr.p->m_errorCode = tmperr;
	opPtr.p->m_errorLine = __LINE__;
	opPtr.p->m_errorNode = c_masterNodeId;
	createIndex_sendReply(signal, opPtr, true);
	return;
      }
      
      // forward initial request plus operation key to all
      req->setOpKey(++c_opRecordSequence);
      NodeReceiverGroup rg(DBDICT, c_aliveNodes);
@@ -7082,10 +7090,19 @@ Dbdict::execDROP_INDX_REQ(Signal* signal)
    jam();
    if (signal->getLength() == DropIndxReq::SignalLength) {
      jam();
      DropIndxRef::ErrorCode tmperr = DropIndxRef::NoError;
      if (getOwnNodeId() != c_masterNodeId) {
        jam();

	err = DropIndxRef::NotMaster;
        tmperr = DropIndxRef::NotMaster;
      } else if (c_blockState == BS_NODE_RESTART) {
        jam();
        tmperr = DropIndxRef::BusyWithNR;
      } else if (c_blockState != BS_IDLE) {
        jam();
        tmperr = DropIndxRef::Busy;
      }
      if (tmperr != DropIndxRef::NoError) {
	err = tmperr;
	goto error;
      }
      // forward initial request plus operation key to all
@@ -10130,6 +10147,17 @@ Dbdict::execDICT_LOCK_REQ(Signal* signal)
    sendDictLockInfoEvent(lockPtr, "lock request by node");
}

// only table and index ops are checked
bool
Dbdict::hasDictLockSchemaOp()
{
  return
    ! c_opCreateTable.isEmpty() ||
    ! c_opDropTable.isEmpty() ||
    ! c_opCreateIndex.isEmpty() ||
    ! c_opDropIndex.isEmpty();
}

void
Dbdict::checkDictLockQueue(Signal* signal, bool poll)
{
@@ -10150,7 +10178,7 @@ Dbdict::checkDictLockQueue(Signal* signal, bool poll)
      break;
    }

    if (c_opRecordPool.getNoOfFree() != c_opRecordPool.getSize()) {
    if (hasDictLockSchemaOp()) {
      jam();
      break;
    }
@@ -10183,7 +10211,7 @@ Dbdict::execDICT_UNLOCK_ORD(Signal* signal)
  if (lockPtr.p->locked) {
    jam();
    ndbrequire(c_blockState == lockPtr.p->lt->blockState);
    ndbrequire(c_opRecordPool.getNoOfFree() == c_opRecordPool.getSize());
    ndbrequire(! hasDictLockSchemaOp());
    ndbrequire(! c_dictLockQueue.hasPrev(lockPtr));

    c_blockState = BS_IDLE;
@@ -10279,7 +10307,7 @@ Dbdict::removeStaleDictLocks(Signal* signal, const Uint32* theFailedNodes)
      if (lockPtr.p->locked) {
        jam();
        ndbrequire(c_blockState == lockPtr.p->lt->blockState);
        ndbrequire(c_opRecordPool.getNoOfFree() == c_opRecordPool.getSize());
        ndbrequire(! hasDictLockSchemaOp());
        ndbrequire(! c_dictLockQueue.hasPrev(lockPtr));

        c_blockState = BS_IDLE;
+3 −0
Original line number Diff line number Diff line
@@ -1650,6 +1650,9 @@ private:
  void sendDictLockInfoEvent(Uint32 pollCount);
  void sendDictLockInfoEvent(DictLockPtr lockPtr, const char* text);

  // check if any schema op exists (conflicting with dict lock)
  bool hasDictLockSchemaOp();

  void checkDictLockQueue(Signal* signal, bool poll);
  void sendDictLockConf(Signal* signal, DictLockPtr lockPtr);
  void sendDictLockRef(Signal* signal, DictLockReq req, Uint32 errorCode);
+2 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public:
   */
  bool next(Uint32 bucket, Iterator & iter) const;

  inline bool isEmpty() const { Iterator iter; return ! first(iter); }
  
private:
  Uint32 mask;
  Uint32 * hashValues;
Loading