From e64b11b094a8b4d04ccc3c9ad57bd0b2dd4dce5f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Sep 2006 10:09:23 +0200 Subject: [PATCH 01/11] ndb - bug#22195 allow bind address for ndbd ndb/include/mgmapi/mgmapi.h: Add support for setting local address in NdbMgmHandle ndb/include/mgmcommon/ConfigRetriever.hpp: Add support for specifying local bindaddress to ConfigRetreiver ndb/include/util/SocketClient.hpp: Add support for setting local address in NdbMgmHandle ndb/src/common/mgmcommon/ConfigRetriever.cpp: Add support for setting local address in NdbMgmHandle ndb/src/common/util/SocketClient.cpp: Add support for setting local address in NdbMgmHandle ndb/src/kernel/vm/Configuration.cpp: Add support for specifying local bindaddress to ndbd ndb/src/mgmapi/mgmapi.cpp: Add support for setting local address in NdbMgmHandle --- ndb/include/mgmapi/mgmapi.h | 13 +++- ndb/include/mgmcommon/ConfigRetriever.hpp | 3 +- ndb/include/util/SocketClient.hpp | 3 +- ndb/src/common/mgmcommon/ConfigRetriever.cpp | 12 +++- ndb/src/common/util/SocketClient.cpp | 73 ++++++++++++++++--- ndb/src/kernel/vm/Configuration.cpp | 11 ++- ndb/src/mgmapi/mgmapi.cpp | 74 ++++++++++++++++++-- 7 files changed, 168 insertions(+), 21 deletions(-) diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index 4e015cc3d7e..208e8aead8d 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -231,7 +231,9 @@ extern "C" { NDB_MGM_SERVER_NOT_CONNECTED = 1010, /** Could not connect to socker */ NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET = 1011, - + /** Could not bind local address */ + NDB_MGM_BIND_ADDRESS = 1012, + /* Alloc node id failures */ /** Generic error, retry may succeed */ NDB_MGM_ALLOCID_ERROR = 1101, @@ -515,6 +517,15 @@ extern "C" { const char *ndb_mgm_get_connected_host(NdbMgmHandle handle); const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz); + /** + * Set local bindaddress + * @param arg - Srting of form "host[:port]" + * @note must be called before connect + * @note Error on binding local address will not be reported until connect + * @return 0 on success + */ + int ndb_mgm_set_bindaddress(NdbMgmHandle, const char * arg); + /** * Gets the connectstring used for a connection * diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp index 1b4ecd56f80..89a1eb976c8 100644 --- a/ndb/include/mgmcommon/ConfigRetriever.hpp +++ b/ndb/include/mgmcommon/ConfigRetriever.hpp @@ -28,7 +28,8 @@ class ConfigRetriever { public: ConfigRetriever(const char * _connect_string, - Uint32 version, Uint32 nodeType); + Uint32 version, Uint32 nodeType, + const char * _bind_address = 0); ~ConfigRetriever(); int do_connect(int no_retries, int retry_delay_in_seconds, int verbose); diff --git a/ndb/include/util/SocketClient.hpp b/ndb/include/util/SocketClient.hpp index bf1ad7d45d6..422560c8a78 100644 --- a/ndb/include/util/SocketClient.hpp +++ b/ndb/include/util/SocketClient.hpp @@ -37,7 +37,8 @@ public: }; unsigned short get_port() { return m_port; }; char *get_server_name() { return m_server_name; }; - NDB_SOCKET_TYPE connect(); + int bind(const char* toaddress, unsigned short toport); + NDB_SOCKET_TYPE connect(const char* toaddress = 0, unsigned short port = 0); bool close(); }; diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index c2b3e8235eb..a0e3a4b74f3 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -45,7 +45,8 @@ //**************************************************************************** ConfigRetriever::ConfigRetriever(const char * _connect_string, - Uint32 version, Uint32 node_type) + Uint32 version, Uint32 node_type, + const char * _bindaddress) { DBUG_ENTER("ConfigRetriever::ConfigRetriever"); @@ -66,6 +67,15 @@ ConfigRetriever::ConfigRetriever(const char * _connect_string, setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); DBUG_VOID_RETURN; } + + if (_bindaddress) + { + if (ndb_mgm_set_bindaddress(m_handle, _bindaddress)) + { + setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); + DBUG_VOID_RETURN; + } + } resetError(); DBUG_VOID_RETURN; } diff --git a/ndb/src/common/util/SocketClient.cpp b/ndb/src/common/util/SocketClient.cpp index 821624eb5c4..f4f2babf312 100644 --- a/ndb/src/common/util/SocketClient.cpp +++ b/ndb/src/common/util/SocketClient.cpp @@ -25,7 +25,7 @@ SocketClient::SocketClient(const char *server_name, unsigned short port, SocketA { m_auth= sa; m_port= port; - m_server_name= strdup(server_name); + m_server_name= server_name ? strdup(server_name) : 0; m_sockfd= NDB_INVALID_SOCKET; } @@ -45,13 +45,16 @@ SocketClient::init() if (m_sockfd != NDB_INVALID_SOCKET) NDB_CLOSE_SOCKET(m_sockfd); - memset(&m_servaddr, 0, sizeof(m_servaddr)); - m_servaddr.sin_family = AF_INET; - m_servaddr.sin_port = htons(m_port); - // Convert ip address presentation format to numeric format - if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) - return false; - + if (m_server_name) + { + memset(&m_servaddr, 0, sizeof(m_servaddr)); + m_servaddr.sin_family = AF_INET; + m_servaddr.sin_port = htons(m_port); + // Convert ip address presentation format to numeric format + if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) + return false; + } + m_sockfd= socket(AF_INET, SOCK_STREAM, 0); if (m_sockfd == NDB_INVALID_SOCKET) { return false; @@ -62,8 +65,45 @@ SocketClient::init() return true; } +int +SocketClient::bind(const char* bindaddress, unsigned short localport) +{ + if (m_sockfd == NDB_INVALID_SOCKET) + return -1; + + struct sockaddr_in local; + memset(&local, 0, sizeof(local)); + local.sin_family = AF_INET; + local.sin_port = htons(localport); + // Convert ip address presentation format to numeric format + if (Ndb_getInAddr(&local.sin_addr, bindaddress)) + { + return errno ? errno : EINVAL; + } + + const int on = 1; + if (setsockopt(m_sockfd, SOL_SOCKET, SO_REUSEADDR, + (const char*)&on, sizeof(on)) == -1) { + + int ret = errno; + NDB_CLOSE_SOCKET(m_sockfd); + m_sockfd= NDB_INVALID_SOCKET; + return errno; + } + + if (::bind(m_sockfd, (struct sockaddr*)&local, sizeof(local)) == -1) + { + int ret = errno; + NDB_CLOSE_SOCKET(m_sockfd); + m_sockfd= NDB_INVALID_SOCKET; + return ret; + } + + return 0; +} + NDB_SOCKET_TYPE -SocketClient::connect() +SocketClient::connect(const char *toaddress, unsigned short toport) { if (m_sockfd == NDB_INVALID_SOCKET) { @@ -74,6 +114,21 @@ SocketClient::connect() return NDB_INVALID_SOCKET; } } + + if (toaddress) + { + if (m_server_name) + free(m_server_name); + m_server_name = strdup(toaddress); + m_port = toport; + memset(&m_servaddr, 0, sizeof(m_servaddr)); + m_servaddr.sin_family = AF_INET; + m_servaddr.sin_port = htons(toport); + // Convert ip address presentation format to numeric format + if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) + return NDB_INVALID_SOCKET; + } + const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr)); if (r == -1) { NDB_CLOSE_SOCKET(m_sockfd); diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 7d1a5ed2ff4..49f16dae3dd 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -58,7 +58,8 @@ NDB_STD_OPTS_VARS; // XXX should be my_bool ??? static int _daemon, _no_daemon, _foreground, _initial, _no_start; static int _initialstart; -static const char* _nowait_nodes; +static const char* _nowait_nodes = 0; +static const char* _bind_address = 0; extern Uint32 g_start_type; extern NdbNodeBitmask g_nowait_nodes; @@ -98,6 +99,10 @@ static struct my_option my_long_options[] = "Perform initial start", (gptr*) &_initialstart, (gptr*) &_initialstart, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "bind-address", OPT_NOWAIT_NODES, + "Local bind address", + (gptr*) &_bind_address, (gptr*) &_bind_address, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void short_usage_sub(void) @@ -257,7 +262,9 @@ Configuration::fetch_configuration(){ m_mgmd_port= 0; m_config_retriever= new ConfigRetriever(getConnectString(), - NDB_VERSION, NODE_TYPE_DB); + NDB_VERSION, + NODE_TYPE_DB, + _bind_address); if (m_config_retriever->hasError()) { diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 4428b158b6b..6287e53541d 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -107,6 +107,7 @@ struct ndb_mgm_handle { int mgmd_version_major; int mgmd_version_minor; int mgmd_version_build; + char * m_bindaddress; }; #define SET_ERROR(h, e, s) setError(h, e, __LINE__, s) @@ -162,6 +163,7 @@ ndb_mgm_create_handle() h->cfg_i = -1; h->errstream = stdout; h->m_name = 0; + h->m_bindaddress = 0; strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE); @@ -209,6 +211,22 @@ ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv) DBUG_RETURN(0); } +extern "C" +int +ndb_mgm_set_bindaddress(NdbMgmHandle handle, const char * arg) +{ + DBUG_ENTER("ndb_mgm_set_bindaddress"); + if (handle->m_bindaddress) + free(handle->m_bindaddress); + + if (arg) + handle->m_bindaddress = strdup(arg); + else + handle->m_bindaddress = 0; + + DBUG_RETURN(0); +} + /** * Destroy a handle */ @@ -235,6 +253,8 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) #endif (*handle)->cfg.~LocalConfig(); my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR)); + if ((*handle)->m_bindaddress) + free((*handle)->m_bindaddress); my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR)); * handle = 0; DBUG_VOID_RETURN; @@ -427,6 +447,7 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, BaseString::snprintf(logname, 64, "mgmapi.log"); handle->logfile = fopen(logname, "w"); #endif + char buf[1024]; /** * Do connect @@ -434,6 +455,50 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, LocalConfig &cfg= handle->cfg; NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET; Uint32 i; + int binderror = 0; + SocketClient s(0, 0); + if (!s.init()) + { + fprintf(handle->errstream, + "Unable to create socket, " + "while trying to connect with connect string: %s\n", + cfg.makeConnectString(buf,sizeof(buf))); + + setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, + "Unable to create socket, " + "while trying to connect with connect string: %s\n", + cfg.makeConnectString(buf,sizeof(buf))); + DBUG_RETURN(-1); + } + + if (handle->m_bindaddress) + { + BaseString::snprintf(buf, sizeof(buf), handle->m_bindaddress); + unsigned short portno = 0; + char * port = strchr(buf, ':'); + if (port != 0) + { + portno = atoi(port+1); + * port = 0; + } + int err; + if ((err = s.bind(buf, portno)) != 0) + { + fprintf(handle->errstream, + "Unable to bind local address %s errno: %d, " + "while trying to connect with connect string: %s\n", + handle->m_bindaddress, err, + cfg.makeConnectString(buf,sizeof(buf))); + + setError(handle, NDB_MGM_BIND_ADDRESS, __LINE__, + "Unable to bind local address %s errno: %d, " + "while trying to connect with connect string: %s\n", + handle->m_bindaddress, err, + cfg.makeConnectString(buf,sizeof(buf))); + DBUG_RETURN(-1); + } + } + while (sockfd == NDB_INVALID_SOCKET) { // do all the mgmt servers @@ -441,8 +506,7 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, { if (cfg.ids[i].type != MgmId_TCP) continue; - SocketClient s(cfg.ids[i].name.c_str(), cfg.ids[i].port); - sockfd = s.connect(); + sockfd = s.connect(cfg.ids[i].name.c_str(), cfg.ids[i].port); if (sockfd != NDB_INVALID_SOCKET) break; } @@ -450,19 +514,17 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, break; #ifndef DBUG_OFF { - char buf[1024]; DBUG_PRINT("info",("Unable to connect with connect string: %s", cfg.makeConnectString(buf,sizeof(buf)))); } #endif if (verbose > 0) { - char buf[1024]; - fprintf(handle->errstream, "Unable to connect with connect string: %s\n", + fprintf(handle->errstream, + "Unable to connect with connect string: %s\n", cfg.makeConnectString(buf,sizeof(buf))); verbose= -1; } if (no_retries == 0) { - char buf[1024]; setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, "Unable to connect with connect string: %s", cfg.makeConnectString(buf,sizeof(buf))); From ba0d1529f542e26222e40c3df4fba22c0d6947cd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Sep 2006 11:57:15 +0200 Subject: [PATCH 02/11] ndb - bug#22195 also bind client to local host name if specified ndb/src/common/transporter/Transporter.cpp: Add binding also of transporter connection (to hostname specified in config file) --- ndb/src/common/transporter/Transporter.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp index 820aa4cfc18..383456f1077 100644 --- a/ndb/src/common/transporter/Transporter.cpp +++ b/ndb/src/common/transporter/Transporter.cpp @@ -60,9 +60,6 @@ Transporter::Transporter(TransporterRegistry &t_reg, } strncpy(localHostName, lHostName, sizeof(localHostName)); - if (strlen(lHostName) > 0) - Ndb_getInAddr(&localHostAddress, lHostName); - DBUG_PRINT("info",("rId=%d lId=%d isServer=%d rHost=%s lHost=%s s_port=%d", remoteNodeId, localNodeId, isServer, remoteHostName, localHostName, @@ -128,10 +125,23 @@ Transporter::connect_client() { return true; if(isMgmConnection) + { sockfd= m_transporter_registry.connect_ndb_mgmd(m_socket_client); + } else + { + if (!m_socket_client->init()) + { + return false; + } + if (strlen(localHostName) > 0) + { + if (m_socket_client->bind(localHostName, 0) != 0) + return false; + } sockfd= m_socket_client->connect(); - + } + return connect_client(sockfd); } From 3b4dd64eaf10491bccdcc0b16945f8f4d91afe41 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Sep 2006 22:01:26 +0200 Subject: [PATCH 03/11] ndb - bug#21535 send new fragdistkeys to all replicas during node recovery to make sure that not 3rd or 4th replicas fragDistKey becomes out of sync ndb/include/kernel/GlobalSignalNumbers.h: new signal UpdateFragDistKeyOrd ndb/include/kernel/signaldata/CopyFrag.hpp: new signal UpdateFragDistKeyOrd ndb/include/ndb_version.h.in: online software upgrade for new signal UpdateFragDistKeyOrd ndb/src/common/debugger/signaldata/SignalNames.cpp: new signal UpdateFragDistKeyOrd ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Send noew list of all replicas in copyfragreq ndb/src/kernel/blocks/dblqh/Dblqh.hpp: new signal UpdateFragDistKeyOrd ndb/src/kernel/blocks/dblqh/DblqhInit.cpp: new signal UpdateFragDistKeyOrd ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: new signal UpdateFragDistKeyOrd --- ndb/include/kernel/GlobalSignalNumbers.h | 1 + ndb/include/kernel/signaldata/CopyFrag.hpp | 14 +++- ndb/include/ndb_version.h.in | 2 + .../debugger/signaldata/SignalNames.cpp | 3 +- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 5 +- ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 1 + ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 4 +- ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 66 ++++++++++++++++++- 8 files changed, 91 insertions(+), 5 deletions(-) diff --git a/ndb/include/kernel/GlobalSignalNumbers.h b/ndb/include/kernel/GlobalSignalNumbers.h index a645a56a64b..76b7d30059e 100644 --- a/ndb/include/kernel/GlobalSignalNumbers.h +++ b/ndb/include/kernel/GlobalSignalNumbers.h @@ -127,6 +127,7 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES; /* 68 unused */ /* 69 unused */ /* 70 unused */ +#define GSN_UPDATE_FRAG_DIST_KEY_ORD 70 #define GSN_ACC_ABORTREQ 71 #define GSN_ACC_CHECK_SCAN 72 #define GSN_ACC_COMMITCONF 73 diff --git a/ndb/include/kernel/signaldata/CopyFrag.hpp b/ndb/include/kernel/signaldata/CopyFrag.hpp index 67b935dda64..3fd5d704727 100644 --- a/ndb/include/kernel/signaldata/CopyFrag.hpp +++ b/ndb/include/kernel/signaldata/CopyFrag.hpp @@ -30,7 +30,8 @@ class CopyFragReq { */ friend class Dblqh; public: - STATIC_CONST( SignalLength = 7 ); + STATIC_CONST( SignalLength = 8 + ); private: Uint32 userPtr; @@ -40,6 +41,8 @@ private: Uint32 nodeId; Uint32 schemaVersion; Uint32 distributionKey; + Uint32 nodeCount; + Uint32 nodeList[1]; }; class CopyFragConf { @@ -84,4 +87,13 @@ private: Uint32 errorCode; }; +struct UpdateFragDistKeyOrd +{ + Uint32 tableId; + Uint32 fragId; + Uint32 fragDistributionKey; + + STATIC_CONST( SignalLength = 3 ); +}; + #endif diff --git a/ndb/include/ndb_version.h.in b/ndb/include/ndb_version.h.in index 7e878803f46..c112a69c5f2 100644 --- a/ndb/include/ndb_version.h.in +++ b/ndb/include/ndb_version.h.in @@ -62,5 +62,7 @@ char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; #define NDBD_DICT_LOCK_VERSION_5 MAKE_VERSION(5,0,23) +#define NDBD_UPDATE_FRAG_DIST_KEY_50 MAKE_VERSION(5,0,26) +#define NDBD_UPDATE_FRAG_DIST_KEY_51 MAKE_VERSION(5,1,12) #endif diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 49e3f505b11..ecc9fc83153 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -636,6 +636,7 @@ const GsnName SignalNames [] = { ,{ GSN_DICT_LOCK_CONF, "DICT_LOCK_CONF" } ,{ GSN_DICT_LOCK_REF, "DICT_LOCK_REF" } ,{ GSN_DICT_UNLOCK_ORD, "DICT_UNLOCK_ORD" } - + + ,{ GSN_UPDATE_FRAG_DIST_KEY_ORD, "UPDATE_FRAG_DIST_KEY_ORD" } }; const unsigned short NO_OF_SIGNAL_NAMES = sizeof(SignalNames)/sizeof(GsnName); diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 1c1fdb41d51..52709792252 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -3078,7 +3078,10 @@ void Dbdih::execCREATE_FRAGCONF(Signal* signal) copyFragReq->nodeId = takeOverPtr.p->toStartingNode; copyFragReq->schemaVersion = tabPtr.p->schemaVersion; copyFragReq->distributionKey = fragPtr.p->distributionKey; - sendSignal(ref, GSN_COPY_FRAGREQ, signal, CopyFragReq::SignalLength, JBB); + copyFragReq->nodeCount = extractNodeInfo(fragPtr.p, + copyFragReq->nodeList); + sendSignal(ref, GSN_COPY_FRAGREQ, signal, + CopyFragReq::SignalLength + copyFragReq->nodeCount, JBB); } else { ndbrequire(takeOverPtr.p->toMasterStatus == TakeOverRecord::COMMIT_CREATE); jam(); diff --git a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index d3ba8521226..299cad16ec1 100644 --- a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -2161,6 +2161,7 @@ private: void execSTORED_PROCCONF(Signal* signal); void execSTORED_PROCREF(Signal* signal); void execCOPY_FRAGREQ(Signal* signal); + void execUPDATE_FRAG_DIST_KEY_ORD(Signal*); void execCOPY_ACTIVEREQ(Signal* signal); void execCOPY_STATEREQ(Signal* signal); void execLQH_TRANSREQ(Signal* signal); diff --git a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 04400f75255..ba18e20f4fb 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -335,7 +335,9 @@ Dblqh::Dblqh(const class Configuration & conf): addRecSignal(GSN_TUX_ADD_ATTRREF, &Dblqh::execTUX_ADD_ATTRREF); addRecSignal(GSN_READ_PSUEDO_REQ, &Dblqh::execREAD_PSUEDO_REQ); - + addRecSignal(GSN_UPDATE_FRAG_DIST_KEY_ORD, + &Dblqh::execUPDATE_FRAG_DIST_KEY_ORD); + initData(); #ifdef VM_TRACE diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 7286481002f..4ccaad7d037 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -9109,7 +9109,12 @@ void Dblqh::execCOPY_FRAGREQ(Signal* signal) ndbrequire(cfirstfreeTcConrec != RNIL); ndbrequire(fragptr.p->m_scanNumberMask.get(NR_ScanNo)); - fragptr.p->fragDistributionKey = copyFragReq->distributionKey; + Uint32 key = fragptr.p->fragDistributionKey = copyFragReq->distributionKey; + + Uint32 nodeCount = copyFragReq->nodeCount; + Uint32 nodeList[MAX_REPLICAS]; + ndbrequire(nodeCount <= MAX_REPLICAS); + memcpy(nodeList, copyFragReq->nodeList, 4*nodeCount); if (DictTabInfo::isOrderedIndex(tabptr.p->tableType)) { jam(); @@ -9184,9 +9189,56 @@ void Dblqh::execCOPY_FRAGREQ(Signal* signal) req->savePointId = tcConnectptr.p->savePointId; sendSignal(tcConnectptr.p->tcAccBlockref, GSN_ACC_SCANREQ, signal, AccScanReq::SignalLength, JBB); + + Uint32 i; + NdbNodeBitmask mask; + for (i = 0; igetDataPtrSend(); + ord->tableId = tabptr.i; + ord->fragId = fragId; + ord->fragDistributionKey = key; + i = 0; + while ((i = mask.find(i+1)) != NdbNodeBitmask::NotFound) + { +#ifdef NDB_VERSION >= MAKE_VERSION(5,1,0) + Uint32 checkversion = NDBD_UPDATE_FRAG_DIST_KEY_51; +#elif NDB_VERSION >= MAKE_VERSION(5,0,0) + Uint32 checkversion = NDBD_UPDATE_FRAG_DIST_KEY_50; +#endif + checkversion = NDB_VERSION; + if (getNodeInfo(i).m_version >= checkversion) + sendSignal(calcLqhBlockRef(i), GSN_UPDATE_FRAG_DIST_KEY_ORD, + signal, UpdateFragDistKeyOrd::SignalLength, JBB); + } + } return; }//Dblqh::execCOPY_FRAGREQ() +void +Dblqh::execUPDATE_FRAG_DIST_KEY_ORD(Signal * signal) +{ + jamEntry(); + UpdateFragDistKeyOrd* ord =(UpdateFragDistKeyOrd*)signal->getDataPtr(); + + tabptr.i = ord->tableId; + ptrCheckGuard(tabptr, ctabrecFileSize, tablerec); + ndbrequire(getFragmentrec(signal, ord->fragId)); + fragptr.p->fragDistributionKey = ord->fragDistributionKey; + + ndbout_c("UpdateFragDistKeyOrd tab: %d frag: %d key: %d", + tabptr.i, + ord->fragId, + ord->fragDistributionKey); +} + void Dblqh::accScanConfCopyLab(Signal* signal) { AccScanConf * const accScanConf = (AccScanConf *)&signal->theData[0]; @@ -18437,6 +18489,18 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal) if(tabPtr.p->tableStatus != Tablerec::NOT_DEFINED){ infoEvent("Table %d Status: %d Usage: %d", i, tabPtr.p->tableStatus, tabPtr.p->usageCount); + + for (Uint32 j = 0; jfragrec[j]) != RNIL) + { + ptrCheckGuard(fragPtr, cfragrecFileSize, fragrecord); + infoEvent(" frag: %d distKey: %u", + tabPtr.p->fragid[j], + fragPtr.p->fragDistributionKey); + } + } } } return; From 144cdb471aad83085b268612650f1d45e825b158 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Sep 2006 22:05:35 +0200 Subject: [PATCH 04/11] ndb - bug#21535 remove accidently left debug code ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: remove accidently left debug code --- ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 4ccaad7d037..22bc884195f 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -9192,11 +9192,6 @@ void Dblqh::execCOPY_FRAGREQ(Signal* signal) Uint32 i; NdbNodeBitmask mask; - for (i = 0; i= MAKE_VERSION(5,0,0) Uint32 checkversion = NDBD_UPDATE_FRAG_DIST_KEY_50; #endif - checkversion = NDB_VERSION; if (getNodeInfo(i).m_version >= checkversion) sendSignal(calcLqhBlockRef(i), GSN_UPDATE_FRAG_DIST_KEY_ORD, signal, UpdateFragDistKeyOrd::SignalLength, JBB); @@ -9232,11 +9226,6 @@ Dblqh::execUPDATE_FRAG_DIST_KEY_ORD(Signal * signal) ptrCheckGuard(tabptr, ctabrecFileSize, tablerec); ndbrequire(getFragmentrec(signal, ord->fragId)); fragptr.p->fragDistributionKey = ord->fragDistributionKey; - - ndbout_c("UpdateFragDistKeyOrd tab: %d frag: %d key: %d", - tabptr.i, - ord->fragId, - ord->fragDistributionKey); } void Dblqh::accScanConfCopyLab(Signal* signal) From 20e2180737792154fc7a43cbdfdd4889b3457869 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Sep 2006 11:18:17 +0200 Subject: [PATCH 05/11] ndb - bug#21535 review, Fix also master being "old" version ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Fix also master being "old" version --- ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 39 +++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 22bc884195f..4739450884c 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -9098,6 +9098,7 @@ void Dblqh::execCOPY_FRAGREQ(Signal* signal) const CopyFragReq * const copyFragReq = (CopyFragReq *)&signal->theData[0]; tabptr.i = copyFragReq->tableId; ptrCheckGuard(tabptr, ctabrecFileSize, tablerec); + Uint32 i; const Uint32 fragId = copyFragReq->fragId; const Uint32 copyPtr = copyFragReq->userPtr; const Uint32 userRef = copyFragReq->userRef; @@ -9111,11 +9112,18 @@ void Dblqh::execCOPY_FRAGREQ(Signal* signal) Uint32 key = fragptr.p->fragDistributionKey = copyFragReq->distributionKey; + Uint32 checkversion = NDB_VERSION >= MAKE_VERSION(5,1,0) ? + NDBD_UPDATE_FRAG_DIST_KEY_51 : NDBD_UPDATE_FRAG_DIST_KEY_50; + Uint32 nodeCount = copyFragReq->nodeCount; - Uint32 nodeList[MAX_REPLICAS]; - ndbrequire(nodeCount <= MAX_REPLICAS); - memcpy(nodeList, copyFragReq->nodeList, 4*nodeCount); - + NdbNodeBitmask nodemask; + if (getNodeInfo(refToNode(userRef)).m_version >= checkversion) + { + ndbrequire(nodeCount <= MAX_REPLICAS); + for (i = 0; inodeList[i]); + } + if (DictTabInfo::isOrderedIndex(tabptr.p->tableType)) { jam(); /** @@ -9189,25 +9197,22 @@ void Dblqh::execCOPY_FRAGREQ(Signal* signal) req->savePointId = tcConnectptr.p->savePointId; sendSignal(tcConnectptr.p->tcAccBlockref, GSN_ACC_SCANREQ, signal, AccScanReq::SignalLength, JBB); - - Uint32 i; - NdbNodeBitmask mask; - ndbrequire(mask.get(getOwnNodeId())); - ndbrequire(mask.get(nodeId)); // cpy dest - if (!mask.isclear()) + + if (! nodemask.isclear()) { - UpdateFragDistKeyOrd* ord =(UpdateFragDistKeyOrd*)signal->getDataPtrSend(); + ndbrequire(nodemask.get(getOwnNodeId())); + ndbrequire(nodemask.get(nodeId)); // cpy dest + nodemask.clear(getOwnNodeId()); + nodemask.clear(nodeId); + + UpdateFragDistKeyOrd* + ord = (UpdateFragDistKeyOrd*)signal->getDataPtrSend(); ord->tableId = tabptr.i; ord->fragId = fragId; ord->fragDistributionKey = key; i = 0; - while ((i = mask.find(i+1)) != NdbNodeBitmask::NotFound) + while ((i = nodemask.find(i+1)) != NdbNodeBitmask::NotFound) { -#ifdef NDB_VERSION >= MAKE_VERSION(5,1,0) - Uint32 checkversion = NDBD_UPDATE_FRAG_DIST_KEY_51; -#elif NDB_VERSION >= MAKE_VERSION(5,0,0) - Uint32 checkversion = NDBD_UPDATE_FRAG_DIST_KEY_50; -#endif if (getNodeInfo(i).m_version >= checkversion) sendSignal(calcLqhBlockRef(i), GSN_UPDATE_FRAG_DIST_KEY_ORD, signal, UpdateFragDistKeyOrd::SignalLength, JBB); From 931af3194bb618a9435b7b9ca0f6996ad4e629f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Sep 2006 11:34:06 +0200 Subject: [PATCH 06/11] ndb - bug#21756 Fix for alter table when node is down...that could cause pain and misery ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Make sure to check table version before retriving from disk --- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 2bb429aeabc..2c6fffe851c 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -2313,7 +2313,8 @@ void Dbdict::checkSchemaStatus(Signal* signal) tablePtr.p->tableType = (DictTabInfo::TableType)oldEntry->m_tableType; // On NR get index from master because index state is not on file - const bool file = c_systemRestart || tablePtr.p->isTable(); + const bool file = (* newEntry == * oldEntry) && + (c_systemRestart || tablePtr.p->isTable()); restartCreateTab(signal, tableId, oldEntry, file); return; From a016cd9e1965ea1cb17c87afbade6f5286056f28 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Sep 2006 16:28:38 +0200 Subject: [PATCH 07/11] ndb - bug#21941 Fix so that scans closed before execute are removed from "scans to send list" ndb/include/ndbapi/NdbTransaction.hpp: Fix so that scans closed before execute are removed from "scans to send list" ndb/src/ndbapi/NdbScanOperation.cpp: Fix so that scans closed before execute are removed from "scans to send list" ndb/src/ndbapi/NdbTransaction.cpp: Fix so that scans closed before execute are removed from "scans to send list" --- ndb/include/ndbapi/NdbTransaction.hpp | 5 +- ndb/src/ndbapi/NdbScanOperation.cpp | 22 ++++++++- ndb/src/ndbapi/NdbTransaction.cpp | 69 +++++++++++++++++++-------- 3 files changed, 74 insertions(+), 22 deletions(-) diff --git a/ndb/include/ndbapi/NdbTransaction.hpp b/ndb/include/ndbapi/NdbTransaction.hpp index a6ba6a11c4d..257956d4fc2 100644 --- a/ndb/include/ndbapi/NdbTransaction.hpp +++ b/ndb/include/ndbapi/NdbTransaction.hpp @@ -657,8 +657,11 @@ private: // Release all cursor operations in connection void releaseOps(NdbOperation*); void releaseScanOperations(NdbIndexScanOperation*); + bool releaseScanOperation(NdbIndexScanOperation** listhead, + NdbIndexScanOperation** listtail, + NdbIndexScanOperation* op); void releaseExecutedScanOperation(NdbIndexScanOperation*); - + // Set the transaction identity of the transaction void setTransactionId(Uint64 aTransactionId); diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index c5a0ebbaf60..a644efe9406 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -678,9 +678,27 @@ void NdbScanOperation::close(bool forceSend, bool releaseOp) theNdbCon = NULL; m_transConnection = NULL; - if (releaseOp && tTransCon) { + if (tTransCon) + { NdbIndexScanOperation* tOp = (NdbIndexScanOperation*)this; - tTransCon->releaseExecutedScanOperation(tOp); + + bool ret = true; + if (theStatus != WaitResponse) + { + /** + * Not executed yet + */ + ret = + tTransCon->releaseScanOperation(&tTransCon->m_theFirstScanOperation, + &tTransCon->m_theLastScanOperation, + tOp); + } + else if (releaseOp) + { + ret = tTransCon->releaseScanOperation(&tTransCon->m_firstExecutedScanOp, + 0, tOp); + } + assert(ret); } tCon->theScanningOp = 0; diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index e82e02067a6..84a7ad568d7 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -978,28 +978,59 @@ void NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp) { DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation"); - DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp)) - - // here is one reason to make op lists doubly linked - if (m_firstExecutedScanOp == cursorOp) { - m_firstExecutedScanOp = (NdbIndexScanOperation*)cursorOp->theNext; - cursorOp->release(); - theNdb->releaseScanOperation(cursorOp); - } else if (m_firstExecutedScanOp != NULL) { - NdbIndexScanOperation* tOp = m_firstExecutedScanOp; - while (tOp->theNext != NULL) { - if (tOp->theNext == cursorOp) { - tOp->theNext = cursorOp->theNext; - cursorOp->release(); - theNdb->releaseScanOperation(cursorOp); - break; - } - tOp = (NdbIndexScanOperation*)tOp->theNext; - } - } + DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp)); + + releaseScanOperation(&m_firstExecutedScanOp, 0, cursorOp); + DBUG_VOID_RETURN; }//NdbTransaction::releaseExecutedScanOperation() +bool +NdbTransaction::releaseScanOperation(NdbIndexScanOperation** listhead, + NdbIndexScanOperation** listtail, + NdbIndexScanOperation* op) +{ + if (* listhead == op) + { + * listhead = (NdbIndexScanOperation*)op->theNext; + if (listtail && *listtail == op) + { + assert(* listhead == 0); + * listtail = 0; + } + + } + else + { + NdbIndexScanOperation* tmp = * listhead; + while (tmp != NULL) + { + if (tmp->theNext == op) + { + tmp->theNext = (NdbIndexScanOperation*)op->theNext; + if (listtail && *listtail == op) + { + assert(op->theNext == 0); + *listtail = tmp; + } + break; + } + tmp = (NdbIndexScanOperation*)tmp->theNext; + } + if (tmp == NULL) + op = NULL; + } + + if (op != NULL) + { + op->release(); + theNdb->releaseScanOperation(op); + return true; + } + + return false; +} + /***************************************************************************** NdbOperation* getNdbOperation(const char* aTableName); From 4b6e6da6819af7c77f7bfd62c45cc17407e7c343 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Sep 2006 13:19:00 +0200 Subject: [PATCH 08/11] ndb - bug#20895 Fix occational LCP hang!!! Make sure only to consider alive nodes in startNextChkpt ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Make sure only to consider alive nodes in startNextChkpt --- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 133 ++++++++++++---------- 1 file changed, 72 insertions(+), 61 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 02ec5782c3e..4b37bb03783 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -9561,73 +9561,84 @@ void Dbdih::startNextChkpt(Signal* signal) nodePtr.i = replicaPtr.p->procNode; ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord); - if (replicaPtr.p->lcpOngoingFlag && - replicaPtr.p->lcpIdStarted < lcpId) { - jam(); - //------------------------------------------------------------------- - // We have found a replica on a node that performs local checkpoint - // that is alive and that have not yet been started. - //------------------------------------------------------------------- - - if (nodePtr.p->noOfStartedChkpt < 2) { - jam(); - /** - * Send LCP_FRAG_ORD to LQH - */ + if (c_lcpState.m_participatingLQH.get(nodePtr.i)) + { + if (replicaPtr.p->lcpOngoingFlag && + replicaPtr.p->lcpIdStarted < lcpId) + { + jam(); + //------------------------------------------------------------------- + // We have found a replica on a node that performs local checkpoint + // that is alive and that have not yet been started. + //------------------------------------------------------------------- - /** - * Mark the replica so with lcpIdStarted == true - */ - replicaPtr.p->lcpIdStarted = lcpId; - - Uint32 i = nodePtr.p->noOfStartedChkpt; - nodePtr.p->startedChkpt[i].tableId = tabPtr.i; - nodePtr.p->startedChkpt[i].fragId = curr.fragmentId; - nodePtr.p->startedChkpt[i].replicaPtr = replicaPtr.i; - nodePtr.p->noOfStartedChkpt = i + 1; - - sendLCP_FRAG_ORD(signal, nodePtr.p->startedChkpt[i]); - } else if (nodePtr.p->noOfQueuedChkpt < 2) { - jam(); - /** - * Put LCP_FRAG_ORD "in queue" - */ - - /** - * Mark the replica so with lcpIdStarted == true - */ - replicaPtr.p->lcpIdStarted = lcpId; - - Uint32 i = nodePtr.p->noOfQueuedChkpt; - nodePtr.p->queuedChkpt[i].tableId = tabPtr.i; - nodePtr.p->queuedChkpt[i].fragId = curr.fragmentId; - nodePtr.p->queuedChkpt[i].replicaPtr = replicaPtr.i; - nodePtr.p->noOfQueuedChkpt = i + 1; - } else { - jam(); - - if(save){ + if (nodePtr.p->noOfStartedChkpt < 2) + { + jam(); /** - * Stop increasing value on first that was "full" + * Send LCP_FRAG_ORD to LQH */ - c_lcpState.currentFragment = curr; - save = false; - } - - busyNodes.set(nodePtr.i); - if(busyNodes.count() == lcpNodes){ + /** - * There were no possibility to start the local checkpoint - * and it was not possible to queue it up. In this case we - * stop the start of local checkpoints until the nodes with a - * backlog have performed more checkpoints. We will return and - * will not continue the process of starting any more checkpoints. + * Mark the replica so with lcpIdStarted == true */ - return; + replicaPtr.p->lcpIdStarted = lcpId; + + Uint32 i = nodePtr.p->noOfStartedChkpt; + nodePtr.p->startedChkpt[i].tableId = tabPtr.i; + nodePtr.p->startedChkpt[i].fragId = curr.fragmentId; + nodePtr.p->startedChkpt[i].replicaPtr = replicaPtr.i; + nodePtr.p->noOfStartedChkpt = i + 1; + + sendLCP_FRAG_ORD(signal, nodePtr.p->startedChkpt[i]); + } + else if (nodePtr.p->noOfQueuedChkpt < 2) + { + jam(); + /** + * Put LCP_FRAG_ORD "in queue" + */ + + /** + * Mark the replica so with lcpIdStarted == true + */ + replicaPtr.p->lcpIdStarted = lcpId; + + Uint32 i = nodePtr.p->noOfQueuedChkpt; + nodePtr.p->queuedChkpt[i].tableId = tabPtr.i; + nodePtr.p->queuedChkpt[i].fragId = curr.fragmentId; + nodePtr.p->queuedChkpt[i].replicaPtr = replicaPtr.i; + nodePtr.p->noOfQueuedChkpt = i + 1; + } + else + { + jam(); + + if(save) + { + /** + * Stop increasing value on first that was "full" + */ + c_lcpState.currentFragment = curr; + save = false; + } + + busyNodes.set(nodePtr.i); + if(busyNodes.count() == lcpNodes) + { + /** + * There were no possibility to start the local checkpoint + * and it was not possible to queue it up. In this case we + * stop the start of local checkpoints until the nodes with a + * backlog have performed more checkpoints. We will return and + * will not continue the process of starting any more checkpoints. + */ + return; + }//if }//if - }//if - } - }//while + } + }//while + } curr.fragmentId++; if (curr.fragmentId >= tabPtr.p->totalfragments) { jam(); From 4d6c4dbe28a331d6d6b2ec0d87823a9bc9b53a47 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Sep 2006 14:08:20 +0200 Subject: [PATCH 09/11] ndb - post merge fixes... storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: merge storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: merge storage/ndb/src/ndbapi/NdbTransaction.cpp: merge --- storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 2 +- storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 2 +- storage/ndb/src/ndbapi/NdbTransaction.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index d53b508e760..d5b77ab2a23 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -2877,7 +2877,7 @@ void Dbdict::checkSchemaStatus(Signal* signal) // On NR get index from master because index state is not on file Uint32 type= oldEntry->m_tableType; const bool file = (* newEntry == * oldEntry) && - (c_systemRestart || !DictTabInfo::isIndex(type); + (c_systemRestart || !DictTabInfo::isIndex(type)); newEntry->m_info_words= oldEntry->m_info_words; restartCreateTab(signal, tableId, oldEntry, newEntry, file); return; diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index d16a6179432..9a7803efbec 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -18344,7 +18344,7 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal) FragrecordPtr fragPtr; if ((fragPtr.i = tabPtr.p->fragrec[j]) != RNIL) { - ptrCheckGuard(fragPtr, cfragrecFileSize, fragrecord); + c_fragment_pool.getPtr(fragPtr); infoEvent(" frag: %d distKey: %u", tabPtr.p->fragid[j], fragPtr.p->fragDistributionKey); diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp index 31c7f43727d..0a7b53ecb3d 100644 --- a/storage/ndb/src/ndbapi/NdbTransaction.cpp +++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp @@ -977,7 +977,7 @@ void releaseScanOperation(); Remark: Release scan op when hupp'ed trans closed (save memory) ******************************************************************************/ void -NdbTransaction::releaseScanOperation(NdbIndexScanOperation* cursorOp) +NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp) { DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation"); DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp)); From 5ad0f036b1ce406f341cf8659b75df3d733d0949 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Sep 2006 15:04:44 +0200 Subject: [PATCH 10/11] ndb - bug#22672 handle also CS_CONNECTED as "abort" in handleFailedApi to keep from falling on assertion in releaseApiCon in case of committed dirtyRead ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: handle also CS_CONNECTED as "abort" to keep from falling on assertion in releaseApiCon in case of committed dirtyRead --- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index ab0981a98ef..59e6bd35baf 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -984,13 +984,6 @@ Dbtc::handleFailedApiNode(Signal* signal, TloopCount += 64; break; case CS_CONNECTED: - /*********************************************************************/ - // The api record is connected to failed node. We need to release the - // connection and set it in a disconnected state. - /*********************************************************************/ - jam(); - releaseApiCon(signal, apiConnectptr.i); - break; case CS_REC_COMMITTING: case CS_RECEIVING: case CS_STARTED: From add68c0c02c961b6d16926298c1e63fc23b521e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Sep 2006 15:20:10 +0200 Subject: [PATCH 11/11] ndb - bug#15303 Fix take-over during SR, remove coupling to lcp/gcp (if systemRestartOngoing()) ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Fix take-over during SR --- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 37 ++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 4b37bb03783..0b0b070899c 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -1265,9 +1265,9 @@ void Dbdih::execNDB_STTOR(Signal* signal) if (isMaster()) { jam(); systemRestartTakeOverLab(signal); - if (anyActiveTakeOver() && false) { + if (anyActiveTakeOver()) + { jam(); - ndbout_c("1 - anyActiveTakeOver == true"); return; } } @@ -2260,6 +2260,8 @@ Dbdih::systemRestartTakeOverLab(Signal* signal) // NOT ACTIVE NODES THAT HAVE NOT YET BEEN TAKEN OVER NEEDS TAKE OVER // IMMEDIATELY. IF WE ARE ALIVE WE TAKE OVER OUR OWN NODE. /*-------------------------------------------------------------------*/ + infoEvent("Take over of node %d started", + nodePtr.i); startTakeOver(signal, RNIL, nodePtr.i, nodePtr.i); }//if break; @@ -2372,6 +2374,12 @@ void Dbdih::nodeRestartTakeOver(Signal* signal, Uint32 startNodeId) *--------------------------------------------------------------------*/ Uint32 takeOverNode = Sysfile::getTakeOverNode(startNodeId, SYSFILE->takeOver); + if(takeOverNode == 0){ + jam(); + warningEvent("Bug in take-over code restarting"); + takeOverNode = startNodeId; + } + startTakeOver(signal, RNIL, startNodeId, takeOverNode); break; } @@ -2525,7 +2533,14 @@ void Dbdih::startTakeOver(Signal* signal, Sysfile::setTakeOverNode(takeOverPtr.p->toFailedNode, SYSFILE->takeOver, startNode); takeOverPtr.p->toMasterStatus = TakeOverRecord::TO_START_COPY; - + + if (getNodeState().getSystemRestartInProgress()) + { + jam(); + checkToCopy(); + checkToCopyCompleted(signal); + return; + } cstartGcpNow = true; }//Dbdih::startTakeOver() @@ -3273,6 +3288,18 @@ void Dbdih::toCopyCompletedLab(Signal * signal, TakeOverRecordPtr takeOverPtr) signal->theData[1] = takeOverPtr.p->toStartingNode; sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB); + if (getNodeState().getSystemRestartInProgress()) + { + jam(); + infoEvent("Take over of node %d complete", takeOverPtr.p->toStartingNode); + setNodeActiveStatus(takeOverPtr.p->toStartingNode, Sysfile::NS_Active); + takeOverPtr.p->toMasterStatus = TakeOverRecord::WAIT_LCP; + takeOverCompleted(takeOverPtr.p->toStartingNode); + checkToCopy(); + checkToCopyCompleted(signal); + return; + } + c_lcpState.immediateLcpStart = true; takeOverPtr.p->toMasterStatus = TakeOverRecord::WAIT_LCP; @@ -3379,16 +3406,12 @@ void Dbdih::execEND_TOCONF(Signal* signal) }//if endTakeOver(takeOverPtr.i); - ndbout_c("2 - endTakeOver"); if (cstartPhase == ZNDB_SPH4) { jam(); - ndbrequire(false); if (anyActiveTakeOver()) { jam(); - ndbout_c("4 - anyActiveTakeOver == true"); return; }//if - ndbout_c("5 - anyActiveTakeOver == false -> ndbsttorry10Lab"); ndbsttorry10Lab(signal, __LINE__); return; }//if