Skip to content

Commit 8ebbf2b

Browse files
author
Ole John Aske
committed
Merge 7.3 -> 7.4
2 parents 09f0a5e + be5a319 commit 8ebbf2b

File tree

4 files changed

+81
-32
lines changed

4 files changed

+81
-32
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -75,6 +75,7 @@ struct SchemaTransImplRef
7575
STATIC_CONST( GSN = GSN_SCHEMA_TRANS_IMPL_REF );
7676
enum ErrorCode {
7777
NoError = 0,
78+
Busy = 701,
7879
NotMaster = 702,
7980
TooManySchemaTrans = 780,
8081
InvalidTransKey = 781,

storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp

+44-30
Original file line numberDiff line numberDiff line change
@@ -27663,17 +27663,26 @@ Dbdict::execSCHEMA_TRANS_BEGIN_REQ(Signal* signal)
2766327663
break;
2766427664
}
2766527665

27666-
if (c_takeOverInProgress)
27666+
if (!localTrans)
2766727667
{
27668-
/**
27669-
* There is a dict takeover in progress. There may thus another
27670-
* transaction that should be rolled backward or forward before we
27671-
* can allow another transaction to start.
27672-
*/
27673-
jam();
27674-
setError(error, SchemaTransBeginRef::Busy, __LINE__);
27675-
break;
27668+
ndbassert(getOwnNodeId() == c_masterNodeId);
27669+
NodeRecordPtr masterNodePtr;
27670+
c_nodes.getPtr(masterNodePtr, c_masterNodeId);
27671+
27672+
if (masterNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
27673+
{
27674+
jam();
27675+
/**
27676+
* There is a dict takeover in progress. There may thus be another
27677+
* transaction that should be rolled backward or forward before we
27678+
* can allow another transaction to start.
27679+
* (Multiple concurrent schema transactions are not supported)
27680+
*/
27681+
setError(error, SchemaTransBeginRef::Busy, __LINE__);
27682+
break;
27683+
}
2767627684
}
27685+
ndbassert(!c_takeOverInProgress);
2767727686

2767827687
if (!check_ndb_versions() && !localTrans)
2767927688
{
@@ -27853,8 +27862,7 @@ Dbdict::execSCHEMA_TRANS_END_REQ(Signal* signal)
2785327862
SchemaTransPtr trans_ptr;
2785427863
ErrorInfo error;
2785527864
do {
27856-
findSchemaTrans(trans_ptr, trans_key);
27857-
if (trans_ptr.isNull()) {
27865+
if (!findSchemaTrans(trans_ptr, trans_key)) {
2785827866
jam();
2785927867
setError(error, SchemaTransEndRef::InvalidTransKey, __LINE__);
2786027868
break;
@@ -27876,31 +27884,32 @@ Dbdict::execSCHEMA_TRANS_END_REQ(Signal* signal)
2787627884
break;
2787727885
}
2787827886

27879-
if (c_takeOverInProgress)
27887+
if (!localTrans)
2788027888
{
27881-
/**
27882-
* There is a dict takeover in progress, and the transaction may thus
27883-
* be in an inconsistent state. Therefore we cannot process this request
27884-
* now.
27885-
*/
27886-
jam();
27887-
setError(error, SchemaTransEndRef::Busy, __LINE__);
27888-
break;
27889+
ndbassert(getOwnNodeId() == c_masterNodeId);
27890+
NodeRecordPtr masterNodePtr;
27891+
c_nodes.getPtr(masterNodePtr, c_masterNodeId);
27892+
27893+
if (masterNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
27894+
{
27895+
jam();
27896+
/**
27897+
* There is a dict takeover in progress.
27898+
* Transaction might be in an inconsistent state where its fate
27899+
* has not been decided yet. When takeover eventually completes,
27900+
* it will ::sendTransClientReply() which will inform the client
27901+
* about the fate of the Txn in a TRANS_END_REP.
27902+
* For now we don't send any reply, and let the client wait for
27903+
* TRANS_END_REP.
27904+
*/
27905+
return;
27906+
}
2788927907
}
27908+
2789027909
#ifdef MARTIN
2789127910
ndbout_c("Dbdict::execSCHEMA_TRANS_END_REQ: trans %u, state %u", trans_ptr.i, trans_ptr.p->m_state);
2789227911
#endif
2789327912

27894-
//XXX Check state
27895-
27896-
if (hasError(trans_ptr.p->m_error))
27897-
{
27898-
jam();
27899-
ndbassert(false);
27900-
setError(error, SchemaTransEndRef::InvalidTransState, __LINE__);
27901-
break;
27902-
}
27903-
2790427913
bool localTrans2 = requestInfo & DictSignal::RF_LOCAL_TRANS;
2790527914
if (localTrans != localTrans2)
2790627915
{
@@ -27910,6 +27919,11 @@ Dbdict::execSCHEMA_TRANS_END_REQ(Signal* signal)
2791027919
break;
2791127920
}
2791227921

27922+
// Assert that we are not in an inconsistent/incomplete state
27923+
ndbassert(!hasError(trans_ptr.p->m_error));
27924+
ndbassert(!c_takeOverInProgress);
27925+
ndbassert(trans_ptr.p->m_counter.done());
27926+
2791327927
trans_ptr.p->m_clientState = TransClient::EndReq;
2791427928

2791527929
const bool doBackground = flags & SchemaTransEndReq::SchemaTransBackground;

storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp

+34
Original file line numberDiff line numberDiff line change
@@ -2231,6 +2231,40 @@ class Dbdict: public SimulatedBlock {
22312231
return;
22322232
}
22332233

2234+
if (!localTrans)
2235+
{
2236+
ndbassert(getOwnNodeId() == c_masterNodeId);
2237+
NodeRecordPtr masterNodePtr;
2238+
c_nodes.getPtr(masterNodePtr, c_masterNodeId);
2239+
2240+
if (masterNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
2241+
{
2242+
jam();
2243+
/**
2244+
* There is a dict takeover in progress, and the transaction may thus
2245+
* be in an inconsistent state where its fate has not been decided yet.
2246+
* If transaction is in error we return that error,
2247+
* else we return 'Busy' which will cause a later retry.
2248+
*/
2249+
if (hasError(trans_ptr.p->m_error))
2250+
{
2251+
jam();
2252+
setError(error, trans_ptr.p->m_error);
2253+
}
2254+
else
2255+
{
2256+
jam();
2257+
setError(error, SchemaTransImplRef::Busy, __LINE__);
2258+
}
2259+
return;
2260+
}
2261+
}
2262+
2263+
// Assert that we are not in an inconsistent/incomplete state
2264+
ndbassert(!hasError(trans_ptr.p->m_error));
2265+
ndbassert(!c_takeOverInProgress);
2266+
ndbassert(trans_ptr.p->m_counter.done());
2267+
22342268
if (!seizeSchemaOp(trans_ptr, op_ptr, t_ptr)) {
22352269
jam();
22362270
setError(error, SchemaTransImplRef::TooManySchemaOps, __LINE__);

storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9384,7 +9384,7 @@ NdbDictInterface::endSchemaTrans(Uint32 flags)
93849384
req->flags = flags;
93859385

93869386
int errCodes[] = {
9387-
SchemaTransBeginRef::NotMaster,
9387+
SchemaTransEndRef::NotMaster,
93889388
0
93899389
};
93909390
int ret = dictSignal(

0 commit comments

Comments
 (0)