Commit f2aa4bcd authored by unknown's avatar unknown

Bug #9249 NDBD crashes when mapping SHM segment w/o correct permission


ndb/include/mgmapi/ndbd_exit_codes.h:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added new exit code for connection setup failure
ndb/include/transporter/TransporterCallback.hpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - corrected transporter callback error codes to have consistant usage of 0x8000 flag for flagging call to do disconnect
ndb/src/common/transporter/SHM_Transporter.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added error info to errors
ndb/src/common/transporter/SHM_Transporter.unix.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added more error info to errors
ndb/src/common/transporter/Transporter.hpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added more info to report error
ndb/src/kernel/blocks/qmgr/QmgrMain.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added error reporting on connect failure
ndb/src/kernel/error/ndbd_exit_codes.c:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - new exit code
ndb/src/kernel/vm/FastScheduler.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - corrected stack overflow issues
ndb/src/kernel/vm/TransporterCallback.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added error info
  - corrected stak overflow issues
ndb/src/kernel/vm/VMSignal.hpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - added struct to allocate smaller Signal
ndb/src/mgmsrv/ConfigInfo.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - enable usage of SHM default section
ndb/src/ndbapi/TransporterFacade.cpp:
  Bug #9249  	NDBD crashes when mapping SHM segment w/o correct permission
  - minor syntax changes
parent f6943edb
...@@ -100,6 +100,7 @@ typedef ndbd_exit_classification_enum ndbd_exit_classification; ...@@ -100,6 +100,7 @@ typedef ndbd_exit_classification_enum ndbd_exit_classification;
#define NDBD_EXIT_SIGNAL_LOST 6051 #define NDBD_EXIT_SIGNAL_LOST 6051
#define NDBD_EXIT_SIGNAL_LOST_SEND_BUFFER_FULL 6052 #define NDBD_EXIT_SIGNAL_LOST_SEND_BUFFER_FULL 6052
#define NDBD_EXIT_ILLEGAL_SIGNAL 6053 #define NDBD_EXIT_ILLEGAL_SIGNAL 6053
#define NDBD_EXIT_CONNECTION_SETUP_FAILED 6054
/* NDBCNTR 6100-> */ /* NDBCNTR 6100-> */
#define NDBD_EXIT_RESTART_TIMEOUT 6100 #define NDBD_EXIT_RESTART_TIMEOUT 6100
......
...@@ -81,7 +81,9 @@ reportConnect(void * callbackObj, NodeId nodeId); ...@@ -81,7 +81,9 @@ reportConnect(void * callbackObj, NodeId nodeId);
void void
reportDisconnect(void * callbackObj, reportDisconnect(void * callbackObj,
NodeId nodeId, Uint32 errNo); NodeId nodeId, Uint32 errNo);
#define TE_DO_DISCONNECT 0x8000
enum TransporterError { enum TransporterError {
TE_NO_ERROR = 0, TE_NO_ERROR = 0,
/** /**
...@@ -111,7 +113,7 @@ enum TransporterError { ...@@ -111,7 +113,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisconnect) * Recommended behavior: setPerformState(PerformDisconnect)
*/ */
TE_INVALID_MESSAGE_LENGTH = 0x8003, TE_INVALID_MESSAGE_LENGTH = 0x3 | TE_DO_DISCONNECT,
/** /**
* TE_INVALID_CHECKSUM * TE_INVALID_CHECKSUM
...@@ -120,7 +122,7 @@ enum TransporterError { ...@@ -120,7 +122,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
TE_INVALID_CHECKSUM = 0x8004, TE_INVALID_CHECKSUM = 0x4 | TE_DO_DISCONNECT,
/** /**
* TE_COULD_NOT_CREATE_SOCKET * TE_COULD_NOT_CREATE_SOCKET
...@@ -129,7 +131,7 @@ enum TransporterError { ...@@ -129,7 +131,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
TE_COULD_NOT_CREATE_SOCKET = 0x8005, TE_COULD_NOT_CREATE_SOCKET = 0x5,
/** /**
* TE_COULD_NOT_BIND_SOCKET * TE_COULD_NOT_BIND_SOCKET
...@@ -138,7 +140,7 @@ enum TransporterError { ...@@ -138,7 +140,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
TE_COULD_NOT_BIND_SOCKET = 0x8006, TE_COULD_NOT_BIND_SOCKET = 0x6,
/** /**
* TE_LISTEN_FAILED * TE_LISTEN_FAILED
...@@ -147,7 +149,7 @@ enum TransporterError { ...@@ -147,7 +149,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
TE_LISTEN_FAILED = 0x8007, TE_LISTEN_FAILED = 0x7,
/** /**
* TE_ACCEPT_RETURN_ERROR * TE_ACCEPT_RETURN_ERROR
...@@ -158,7 +160,7 @@ enum TransporterError { ...@@ -158,7 +160,7 @@ enum TransporterError {
* Recommended behavior: Ignore * Recommended behavior: Ignore
* (or possible do setPerformState(PerformDisconnect) * (or possible do setPerformState(PerformDisconnect)
*/ */
TE_ACCEPT_RETURN_ERROR = 0x8008 TE_ACCEPT_RETURN_ERROR = 0x8
/** /**
* TE_SHM_DISCONNECT * TE_SHM_DISCONNECT
...@@ -167,7 +169,7 @@ enum TransporterError { ...@@ -167,7 +169,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SHM_DISCONNECT = 0x800b ,TE_SHM_DISCONNECT = 0xb | TE_DO_DISCONNECT
/** /**
* TE_SHM_IPC_STAT * TE_SHM_IPC_STAT
...@@ -178,7 +180,12 @@ enum TransporterError { ...@@ -178,7 +180,12 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SHM_IPC_STAT = 0x800c ,TE_SHM_IPC_STAT = 0xc | TE_DO_DISCONNECT
/**
* Permanent error
*/
,TE_SHM_IPC_PERMANENT = 0x21
/** /**
* TE_SHM_UNABLE_TO_CREATE_SEGMENT * TE_SHM_UNABLE_TO_CREATE_SEGMENT
...@@ -188,7 +195,7 @@ enum TransporterError { ...@@ -188,7 +195,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SHM_UNABLE_TO_CREATE_SEGMENT = 0x800d ,TE_SHM_UNABLE_TO_CREATE_SEGMENT = 0xd
/** /**
* TE_SHM_UNABLE_TO_ATTACH_SEGMENT * TE_SHM_UNABLE_TO_ATTACH_SEGMENT
...@@ -198,7 +205,7 @@ enum TransporterError { ...@@ -198,7 +205,7 @@ enum TransporterError {
* *
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SHM_UNABLE_TO_ATTACH_SEGMENT = 0x800e ,TE_SHM_UNABLE_TO_ATTACH_SEGMENT = 0xe
/** /**
* TE_SHM_UNABLE_TO_REMOVE_SEGMENT * TE_SHM_UNABLE_TO_REMOVE_SEGMENT
...@@ -208,12 +215,12 @@ enum TransporterError { ...@@ -208,12 +215,12 @@ enum TransporterError {
* Recommended behavior: Ignore (not much to do) * Recommended behavior: Ignore (not much to do)
* Print warning to logfile * Print warning to logfile
*/ */
,TE_SHM_UNABLE_TO_REMOVE_SEGMENT = 0x800f ,TE_SHM_UNABLE_TO_REMOVE_SEGMENT = 0xf
,TE_TOO_SMALL_SIGID = 0x0010 ,TE_TOO_SMALL_SIGID = 0x10
,TE_TOO_LARGE_SIGID = 0x0011 ,TE_TOO_LARGE_SIGID = 0x11
,TE_WAIT_STACK_FULL = 0x8012 ,TE_WAIT_STACK_FULL = 0x12 | TE_DO_DISCONNECT
,TE_RECEIVE_BUFFER_FULL = 0x8013 ,TE_RECEIVE_BUFFER_FULL = 0x13 | TE_DO_DISCONNECT
/** /**
* TE_SIGNAL_LOST_SEND_BUFFER_FULL * TE_SIGNAL_LOST_SEND_BUFFER_FULL
...@@ -222,7 +229,7 @@ enum TransporterError { ...@@ -222,7 +229,7 @@ enum TransporterError {
* a signal is dropped!! very bad very bad * a signal is dropped!! very bad very bad
* *
*/ */
,TE_SIGNAL_LOST_SEND_BUFFER_FULL = 0x8014 ,TE_SIGNAL_LOST_SEND_BUFFER_FULL = 0x14 | TE_DO_DISCONNECT
/** /**
* TE_SIGNAL_LOST * TE_SIGNAL_LOST
...@@ -231,14 +238,14 @@ enum TransporterError { ...@@ -231,14 +238,14 @@ enum TransporterError {
* a signal is dropped!! very bad very bad * a signal is dropped!! very bad very bad
* *
*/ */
,TE_SIGNAL_LOST = 0x8015 ,TE_SIGNAL_LOST = 0x15
/** /**
* TE_SEND_BUFFER_FULL * TE_SEND_BUFFER_FULL
* *
* The send buffer was full, but sleeping for a while solved it * The send buffer was full, but sleeping for a while solved it
*/ */
,TE_SEND_BUFFER_FULL = 0x0016 ,TE_SEND_BUFFER_FULL = 0x16
/** /**
* TE_SCI_UNABLE_TO_CLOSE_CHANNEL * TE_SCI_UNABLE_TO_CLOSE_CHANNEL
...@@ -246,7 +253,7 @@ enum TransporterError { ...@@ -246,7 +253,7 @@ enum TransporterError {
* Unable to close the sci channel and the resources allocated by * Unable to close the sci channel and the resources allocated by
* the sisci api. * the sisci api.
*/ */
,TE_SCI_UNABLE_TO_CLOSE_CHANNEL = 0x8016 ,TE_SCI_UNABLE_TO_CLOSE_CHANNEL = 0x22
/** /**
* TE_SCI_LINK_ERROR * TE_SCI_LINK_ERROR
...@@ -255,7 +262,7 @@ enum TransporterError { ...@@ -255,7 +262,7 @@ enum TransporterError {
* No point in continuing. Must check the connections. * No point in continuing. Must check the connections.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_LINK_ERROR = 0x8017 ,TE_SCI_LINK_ERROR = 0x0017
/** /**
* TE_SCI_UNABLE_TO_START_SEQUENCE * TE_SCI_UNABLE_TO_START_SEQUENCE
...@@ -264,14 +271,14 @@ enum TransporterError { ...@@ -264,14 +271,14 @@ enum TransporterError {
* are exumed or no sequence has been created. * are exumed or no sequence has been created.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_UNABLE_TO_START_SEQUENCE = 0x8018 ,TE_SCI_UNABLE_TO_START_SEQUENCE = 0x18 | TE_DO_DISCONNECT
/** /**
* TE_SCI_UNABLE_TO_REMOVE_SEQUENCE * TE_SCI_UNABLE_TO_REMOVE_SEQUENCE
* *
* Could not remove a sequence * Could not remove a sequence
*/ */
,TE_SCI_UNABLE_TO_REMOVE_SEQUENCE = 0x8019 ,TE_SCI_UNABLE_TO_REMOVE_SEQUENCE = 0x19 | TE_DO_DISCONNECT
/** /**
* TE_SCI_UNABLE_TO_CREATE_SEQUENCE * TE_SCI_UNABLE_TO_CREATE_SEQUENCE
...@@ -280,7 +287,7 @@ enum TransporterError { ...@@ -280,7 +287,7 @@ enum TransporterError {
* exempted. Must reboot. * exempted. Must reboot.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_UNABLE_TO_CREATE_SEQUENCE = 0x801a ,TE_SCI_UNABLE_TO_CREATE_SEQUENCE = 0x1a | TE_DO_DISCONNECT
/** /**
* TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR * TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR
...@@ -288,7 +295,7 @@ enum TransporterError { ...@@ -288,7 +295,7 @@ enum TransporterError {
* Tried to send data on redundant link but failed. * Tried to send data on redundant link but failed.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR = 0x801b ,TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR = 0x1b | TE_DO_DISCONNECT
/** /**
* TE_SCI_CANNOT_INIT_LOCALSEGMENT * TE_SCI_CANNOT_INIT_LOCALSEGMENT
...@@ -297,7 +304,7 @@ enum TransporterError { ...@@ -297,7 +304,7 @@ enum TransporterError {
* gone wrong (no system resources). Must reboot. * gone wrong (no system resources). Must reboot.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_CANNOT_INIT_LOCALSEGMENT = 0x801c ,TE_SCI_CANNOT_INIT_LOCALSEGMENT = 0x1c | TE_DO_DISCONNECT
/** /**
* TE_SCI_CANNOT_MAP_REMOTESEGMENT * TE_SCI_CANNOT_MAP_REMOTESEGMENT
...@@ -306,7 +313,7 @@ enum TransporterError { ...@@ -306,7 +313,7 @@ enum TransporterError {
* Must reboot system. * Must reboot system.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_CANNOT_MAP_REMOTESEGMENT = 0x801d ,TE_SCI_CANNOT_MAP_REMOTESEGMENT = 0x1d | TE_DO_DISCONNECT
/** /**
* TE_SCI_UNABLE_TO_UNMAP_SEGMENT * TE_SCI_UNABLE_TO_UNMAP_SEGMENT
...@@ -314,7 +321,7 @@ enum TransporterError { ...@@ -314,7 +321,7 @@ enum TransporterError {
* Cannot free the resources used by this segment (step 1). * Cannot free the resources used by this segment (step 1).
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_UNABLE_TO_UNMAP_SEGMENT = 0x801e ,TE_SCI_UNABLE_TO_UNMAP_SEGMENT = 0x1e | TE_DO_DISCONNECT
/** /**
* TE_SCI_UNABLE_TO_REMOVE_SEGMENT * TE_SCI_UNABLE_TO_REMOVE_SEGMENT
...@@ -324,7 +331,7 @@ enum TransporterError { ...@@ -324,7 +331,7 @@ enum TransporterError {
* to map more segment * to map more segment
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_UNABLE_TO_REMOVE_SEGMENT = 0x801f ,TE_SCI_UNABLE_TO_REMOVE_SEGMENT = 0x1f | TE_DO_DISCONNECT
/** /**
* TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT * TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT
...@@ -332,15 +339,18 @@ enum TransporterError { ...@@ -332,15 +339,18 @@ enum TransporterError {
* Cannot disconnect from a remote segment. * Cannot disconnect from a remote segment.
* Recommended behavior: setPerformState(PerformDisonnect) * Recommended behavior: setPerformState(PerformDisonnect)
*/ */
,TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT = 0x8020 ,TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT = 0x20 | TE_DO_DISCONNECT
/* Used 0x21 */
/* Used 0x22 */
}; };
/** /**
* Report error * Report error
*/ */
void void
reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode); reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode,
const char *info = 0);
void void
transporter_recv_from(void* callbackObj, NodeId node); transporter_recv_from(void* callbackObj, NodeId node);
......
...@@ -47,6 +47,9 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, ...@@ -47,6 +47,9 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
shmKey(_shmKey), shmKey(_shmKey),
shmSize(_shmSize) shmSize(_shmSize)
{ {
#ifndef NDB_WIN32
shmId= 0;
#endif
_shmSegCreated = false; _shmSegCreated = false;
_attached = false; _attached = false;
...@@ -202,7 +205,8 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) ...@@ -202,7 +205,8 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
// Create // Create
if(!_shmSegCreated){ if(!_shmSegCreated){
if (!ndb_shm_create()) { if (!ndb_shm_create()) {
report_error(TE_SHM_UNABLE_TO_CREATE_SEGMENT); make_error_info(buf, sizeof(buf));
report_error(TE_SHM_UNABLE_TO_CREATE_SEGMENT, buf);
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_RETURN(false); DBUG_RETURN(false);
} }
...@@ -212,7 +216,8 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) ...@@ -212,7 +216,8 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
// Attach // Attach
if(!_attached){ if(!_attached){
if (!ndb_shm_attach()) { if (!ndb_shm_attach()) {
report_error(TE_SHM_UNABLE_TO_ATTACH_SEGMENT); make_error_info(buf, sizeof(buf));
report_error(TE_SHM_UNABLE_TO_ATTACH_SEGMENT, buf);
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_RETURN(false); DBUG_RETURN(false);
} }
...@@ -224,7 +229,8 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) ...@@ -224,7 +229,8 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
m_transporter_registry.m_shm_own_pid); m_transporter_registry.m_shm_own_pid);
// Wait for ok from client // Wait for ok from client
if (s_input.gets(buf, 256) == 0) DBUG_PRINT("info", ("Wait for ok from client"));
if (s_input.gets(buf, sizeof(buf)) == 0)
{ {
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_RETURN(false); DBUG_RETURN(false);
...@@ -262,10 +268,8 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) ...@@ -262,10 +268,8 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
SocketOutputStream s_output(sockfd); SocketOutputStream s_output(sockfd);
char buf[256]; char buf[256];
#if 1
#endif
// Wait for server to create and attach // Wait for server to create and attach
DBUG_PRINT("info", ("Wait for server to create and attach"));
if (s_input.gets(buf, 256) == 0) { if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_PRINT("error", ("Server id %d did not attach", DBUG_PRINT("error", ("Server id %d did not attach",
...@@ -293,7 +297,8 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) ...@@ -293,7 +297,8 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
// Attach // Attach
if(!_attached){ if(!_attached){
if (!ndb_shm_attach()) { if (!ndb_shm_attach()) {
report_error(TE_SHM_UNABLE_TO_ATTACH_SEGMENT); make_error_info(buf, sizeof(buf));
report_error(TE_SHM_UNABLE_TO_ATTACH_SEGMENT, buf);
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_PRINT("error", ("Failed attach of shm seg to node %d", DBUG_PRINT("error", ("Failed attach of shm seg to node %d",
remoteNodeId)); remoteNodeId));
...@@ -310,6 +315,7 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) ...@@ -310,6 +315,7 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
if (r) { if (r) {
// Wait for ok from server // Wait for ok from server
DBUG_PRINT("info", ("Wait for ok from server"));
if (s_input.gets(buf, 256) == 0) { if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd); NDB_CLOSE_SOCKET(sockfd);
DBUG_PRINT("error", ("No ok from server node %d", DBUG_PRINT("error", ("No ok from server node %d",
...@@ -330,8 +336,6 @@ bool ...@@ -330,8 +336,6 @@ bool
SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd) SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
{ {
if (!checkConnected()) { if (!checkConnected()) {
DBUG_PRINT("error", ("Already connected to node %d",
remoteNodeId));
return false; return false;
} }
......
...@@ -170,6 +170,8 @@ private: ...@@ -170,6 +170,8 @@ private:
bool hasDataToRead() const { bool hasDataToRead() const {
return reader->empty() == false; return reader->empty() == false;
} }
void make_error_info(char info[], int sz);
}; };
#endif #endif
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
void SHM_Transporter::make_error_info(char info[], int sz)
{
snprintf(info,sz,"Shm key=%d sz=%d id=%d",
shmKey, shmSize, shmId);
}
bool bool
SHM_Transporter::ndb_shm_create() SHM_Transporter::ndb_shm_create()
{ {
...@@ -64,12 +70,30 @@ SHM_Transporter::checkConnected(){ ...@@ -64,12 +70,30 @@ SHM_Transporter::checkConnected(){
struct shmid_ds info; struct shmid_ds info;
const int res = shmctl(shmId, IPC_STAT, &info); const int res = shmctl(shmId, IPC_STAT, &info);
if(res == -1){ if(res == -1){
report_error(TE_SHM_IPC_STAT); char buf[128];
int r= snprintf(buf, sizeof(buf),
"shmctl(%d, IPC_STAT) errno: %d(%s). ", shmId,
errno, strerror(errno));
make_error_info(buf+r, sizeof(buf)-r);
DBUG_PRINT("error",(buf));
switch (errno)
{
case EACCES:
report_error(TE_SHM_IPC_PERMANENT, buf);
break;
default:
report_error(TE_SHM_IPC_STAT, buf);
break;
}
return false; return false;
} }
if(info.shm_nattch != 2){ if(info.shm_nattch != 2){
char buf[128];
make_error_info(buf, sizeof(buf));
report_error(TE_SHM_DISCONNECT); report_error(TE_SHM_DISCONNECT);
DBUG_PRINT("error", ("Already connected to node %d",
remoteNodeId));
return false; return false;
} }
return true; return true;
...@@ -91,6 +115,8 @@ SHM_Transporter::disconnectImpl(){ ...@@ -91,6 +115,8 @@ SHM_Transporter::disconnectImpl(){
if(isServer && _shmSegCreated){ if(isServer && _shmSegCreated){
const int res = shmctl(shmId, IPC_RMID, 0); const int res = shmctl(shmId, IPC_RMID, 0);
if(res == -1){ if(res == -1){
char buf[64];
make_error_info(buf, sizeof(buf));
report_error(TE_SHM_UNABLE_TO_REMOVE_SEGMENT); report_error(TE_SHM_UNABLE_TO_REMOVE_SEGMENT);
return; return;
} }
......
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
#include <windows.h> #include <windows.h>
void SHM_Transporter::make_error_info(char info[], int sz)
{
snprintf(info,sz,"Shm key=%d sz=%d",
shmKey, shmSize);
}
bool bool
SHM_Transporter::connectServer(Uint32 timeOutMillis){ SHM_Transporter::connectServer(Uint32 timeOutMillis){
if(!_shmSegCreated) if(!_shmSegCreated)
......
...@@ -161,7 +161,8 @@ protected: ...@@ -161,7 +161,8 @@ protected:
TransporterRegistry &m_transporter_registry; TransporterRegistry &m_transporter_registry;
void *get_callback_obj() { return m_transporter_registry.callbackObj; }; void *get_callback_obj() { return m_transporter_registry.callbackObj; };
void report_disconnect(int err){m_transporter_registry.report_disconnect(remoteNodeId,err);}; void report_disconnect(int err){m_transporter_registry.report_disconnect(remoteNodeId,err);};
void report_error(enum TransporterError err){reportError(get_callback_obj(),remoteNodeId,err);}; void report_error(enum TransporterError err, const char *info = 0)
{ reportError(get_callback_obj(), remoteNodeId, err, info); };
}; };
inline inline
......
...@@ -1508,8 +1508,8 @@ TransporterRegistry::startReceiving() ...@@ -1508,8 +1508,8 @@ TransporterRegistry::startReceiving()
{ {
DBUG_PRINT("error",("Install failed")); DBUG_PRINT("error",("Install failed"));
g_eventLogger.error("Failed to install signal handler for" g_eventLogger.error("Failed to install signal handler for"
" SHM transporter errno: %d (%s)", errno, " SHM transporter, signum %d, errno: %d (%s)",
strerror(errno)); g_ndb_shm_signum, errno, strerror(errno));
} }
} }
#endif // NDB_SHM_TRANSPORTER #endif // NDB_SHM_TRANSPORTER
......
...@@ -1823,11 +1823,14 @@ void Qmgr::execNDB_FAILCONF(Signal* signal) ...@@ -1823,11 +1823,14 @@ void Qmgr::execNDB_FAILCONF(Signal* signal)
/*******************************/ /*******************************/
/* DISCONNECT_REP */ /* DISCONNECT_REP */
/*******************************/ /*******************************/
const char *lookupConnectionError(Uint32 err);
void Qmgr::execDISCONNECT_REP(Signal* signal) void Qmgr::execDISCONNECT_REP(Signal* signal)
{ {
jamEntry(); jamEntry();
const DisconnectRep * const rep = (DisconnectRep *)&signal->theData[0]; const DisconnectRep * const rep = (DisconnectRep *)&signal->theData[0];
const Uint32 nodeId = rep->nodeId; const Uint32 nodeId = rep->nodeId;
const Uint32 err = rep->err;
c_connectedNodes.clear(nodeId); c_connectedNodes.clear(nodeId);
NodeRecPtr nodePtr; NodeRecPtr nodePtr;
...@@ -1838,10 +1841,17 @@ void Qmgr::execDISCONNECT_REP(Signal* signal) ...@@ -1838,10 +1841,17 @@ void Qmgr::execDISCONNECT_REP(Signal* signal)
jam(); jam();
break; break;
case ZINIT: case ZINIT:
ndbrequire(false);
case ZSTARTING: case ZSTARTING:
progError(__LINE__, NDBD_EXIT_CONNECTION_SETUP_FAILED,
lookupConnectionError(err));
ndbrequire(false);
case ZPREPARE_FAIL: case ZPREPARE_FAIL:
ndbrequire(false);
case ZFAIL_CLOSING: case ZFAIL_CLOSING:
ndbrequire(false);
case ZAPI_ACTIVE: case ZAPI_ACTIVE:
ndbrequire(false);
case ZAPI_INACTIVE: case ZAPI_INACTIVE:
ndbrequire(false); ndbrequire(false);
} }
......
...@@ -95,6 +95,7 @@ static const ErrStruct errArray[] = ...@@ -95,6 +95,7 @@ static const ErrStruct errArray[] =
{NDBD_EXIT_SIGNAL_LOST, XIE, "Signal lost (unknown reason)"}, {NDBD_EXIT_SIGNAL_LOST, XIE, "Signal lost (unknown reason)"},
{NDBD_EXIT_ILLEGAL_SIGNAL, XIE, {NDBD_EXIT_ILLEGAL_SIGNAL, XIE,
"Illegal signal (version mismatch a possibility)"}, "Illegal signal (version mismatch a possibility)"},
{NDBD_EXIT_CONNECTION_SETUP_FAILED, XCE, "Connection setup failed"},
/* Ndbcntr */ /* Ndbcntr */
{NDBD_EXIT_RESTART_TIMEOUT, XCE, {NDBD_EXIT_RESTART_TIMEOUT, XCE,
......
...@@ -394,7 +394,8 @@ void print_restart(FILE * output, Signal* signal, Uint32 aLevel); ...@@ -394,7 +394,8 @@ void print_restart(FILE * output, Signal* signal, Uint32 aLevel);
void FastScheduler::dumpSignalMemory(FILE * output) void FastScheduler::dumpSignalMemory(FILE * output)
{ {
Signal signal; SignalT<25> signalT;
Signal &signal= *(Signal*)&signalT;
Uint32 ReadPtr[5]; Uint32 ReadPtr[5];
Uint32 tJob; Uint32 tJob;
Uint32 tLastJob; Uint32 tLastJob;
...@@ -483,17 +484,17 @@ print_restart(FILE * output, Signal* signal, Uint32 aLevel) ...@@ -483,17 +484,17 @@ print_restart(FILE * output, Signal* signal, Uint32 aLevel)
*/ */
void void
FastScheduler::reportDoJobStatistics(Uint32 tMeanLoopCount) { FastScheduler::reportDoJobStatistics(Uint32 tMeanLoopCount) {
Signal signal; SignalT<2> signalT;
Signal &signal= *(Signal*)&signalT;
memset(&signal.header, 0, sizeof(signal.header)); memset(&signal.header, 0, sizeof(signal.header));
signal.header.theLength = 2;
signal.header.theSendersSignalId = 0;
signal.header.theSendersBlockRef = numberToRef(0, 0);
signal.theData[0] = NDB_LE_JobStatistic; signal.theData[0] = NDB_LE_JobStatistic;
signal.theData[1] = tMeanLoopCount; signal.theData[1] = tMeanLoopCount;
memset(&signal.header, 0, sizeof(SignalHeader));
signal.header.theLength = 2;
signal.header.theSendersSignalId = 0;
signal.header.theSendersBlockRef = numberToRef(0, 0);
execute(&signal, JBA, CMVMI, GSN_EVENT_REP); execute(&signal, JBA, CMVMI, GSN_EVENT_REP);
} }
...@@ -39,6 +39,26 @@ ...@@ -39,6 +39,26 @@
*/ */
SectionSegmentPool g_sectionSegmentPool; SectionSegmentPool g_sectionSegmentPool;
struct ConnectionError
{
enum TransporterError err;
const char *text;
};
static const ConnectionError connectionError[] =
{
{ TE_NO_ERROR, "No error"},
{ TE_SHM_UNABLE_TO_CREATE_SEGMENT, "Unable to create shared memory segment"},
{ (enum TransporterError) -1, "No connection error message available (please report a bug)"}
};
const char *lookupConnectionError(Uint32 err)
{
int i= 0;
while ((Uint32)connectionError[i].err != err && (Uint32)connectionError[i].err != -1);
return connectionError[i].text;
}
bool bool
import(Ptr<SectionSegment> & first, const Uint32 * src, Uint32 len){ import(Ptr<SectionSegment> & first, const Uint32 * src, Uint32 len){
/** /**
...@@ -306,30 +326,54 @@ checkJobBuffer() { ...@@ -306,30 +326,54 @@ checkJobBuffer() {
} }
void void
reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode){ reportError(void * callbackObj, NodeId nodeId,
TransporterError errorCode, const char *info)
{
#ifdef DEBUG_TRANSPORTER #ifdef DEBUG_TRANSPORTER
char buf[255]; ndbout_c("reportError (%d, 0x%x) %s", nodeId, errorCode, info ? info : "")
sprintf(buf, "reportError (%d, 0x%x)", nodeId, errorCode);
ndbout << buf << endl;
#endif #endif
if(errorCode == TE_SIGNAL_LOST_SEND_BUFFER_FULL){ DBUG_ENTER("reportError");
DBUG_PRINT("info",("nodeId %d errorCode: 0x%x info: %s",
nodeId, errorCode, info));
switch (errorCode)
{
case TE_SIGNAL_LOST_SEND_BUFFER_FULL:
{
char msg[64];
snprintf(msg, sizeof(msg), "Remote note id %d.%s%s", nodeId,
info ? " " : "", info ? info : "");
ErrorReporter::handleError(NDBD_EXIT_SIGNAL_LOST_SEND_BUFFER_FULL, ErrorReporter::handleError(NDBD_EXIT_SIGNAL_LOST_SEND_BUFFER_FULL,
"", __FILE__, msg, __FILE__, NST_ErrorHandler);
NST_ErrorHandler);
} }
case TE_SIGNAL_LOST:
if(errorCode == TE_SIGNAL_LOST){ {
char msg[64];
snprintf(msg, sizeof(msg), "Remote node id %d,%s%s", nodeId,
info ? " " : "", info ? info : "");
ErrorReporter::handleError(NDBD_EXIT_SIGNAL_LOST, ErrorReporter::handleError(NDBD_EXIT_SIGNAL_LOST,
"", __FILE__, msg, __FILE__, NST_ErrorHandler);
NST_ErrorHandler);
} }
case TE_SHM_IPC_PERMANENT:
if(errorCode & 0x8000){ {
char msg[128];
snprintf(msg, sizeof(msg),
"Remote node id %d.%s%s",
nodeId, info ? " " : "", info ? info : "");
ErrorReporter::handleError(NDBD_EXIT_CONNECTION_SETUP_FAILED,
msg, __FILE__, NST_ErrorHandler);
}
default:
break;
}
if(errorCode & & TE_DO_DISCONNECT){
reportDisconnect(callbackObj, nodeId, errorCode); reportDisconnect(callbackObj, nodeId, errorCode);
} }
Signal signal; SignalT<3> signalT;
Signal &signal= *(Signal*)&signalT;
memset(&signal.header, 0, sizeof(signal.header)); memset(&signal.header, 0, sizeof(signal.header));
...@@ -345,6 +389,8 @@ reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode){ ...@@ -345,6 +389,8 @@ reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode){
signal.header.theSendersSignalId = 0; signal.header.theSendersSignalId = 0;
signal.header.theSendersBlockRef = numberToRef(0, globalData.ownId); signal.header.theSendersBlockRef = numberToRef(0, globalData.ownId);
globalScheduler.execute(&signal, JBA, CMVMI, GSN_EVENT_REP); globalScheduler.execute(&signal, JBA, CMVMI, GSN_EVENT_REP);
DBUG_VOID_RETURN;
} }
/** /**
...@@ -354,7 +400,8 @@ void ...@@ -354,7 +400,8 @@ void
reportSendLen(void * callbackObj, reportSendLen(void * callbackObj,
NodeId nodeId, Uint32 count, Uint64 bytes){ NodeId nodeId, Uint32 count, Uint64 bytes){
Signal signal; SignalT<3> signalT;
Signal &signal= *(Signal*)&signalT;
memset(&signal.header, 0, sizeof(signal.header)); memset(&signal.header, 0, sizeof(signal.header));
signal.header.theLength = 3; signal.header.theLength = 3;
...@@ -373,7 +420,8 @@ void ...@@ -373,7 +420,8 @@ void
reportReceiveLen(void * callbackObj, reportReceiveLen(void * callbackObj,
NodeId nodeId, Uint32 count, Uint64 bytes){ NodeId nodeId, Uint32 count, Uint64 bytes){
Signal signal; SignalT<3> signalT;
Signal &signal= *(Signal*)&signalT;
memset(&signal.header, 0, sizeof(signal.header)); memset(&signal.header, 0, sizeof(signal.header));
signal.header.theLength = 3; signal.header.theLength = 3;
...@@ -392,7 +440,8 @@ reportReceiveLen(void * callbackObj, ...@@ -392,7 +440,8 @@ reportReceiveLen(void * callbackObj,
void void
reportConnect(void * callbackObj, NodeId nodeId){ reportConnect(void * callbackObj, NodeId nodeId){
Signal signal; SignalT<1> signalT;
Signal &signal= *(Signal*)&signalT;
memset(&signal.header, 0, sizeof(signal.header)); memset(&signal.header, 0, sizeof(signal.header));
signal.header.theLength = 1; signal.header.theLength = 1;
...@@ -409,7 +458,10 @@ reportConnect(void * callbackObj, NodeId nodeId){ ...@@ -409,7 +458,10 @@ reportConnect(void * callbackObj, NodeId nodeId){
void void
reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){ reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){
Signal signal; DBUG_ENTER("reportDisconnect");
SignalT<sizeof(DisconnectRep)/4> signalT;
Signal &signal= *(Signal*)&signalT;
memset(&signal.header, 0, sizeof(signal.header)); memset(&signal.header, 0, sizeof(signal.header));
signal.header.theLength = DisconnectRep::SignalLength; signal.header.theLength = DisconnectRep::SignalLength;
...@@ -422,6 +474,8 @@ reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){ ...@@ -422,6 +474,8 @@ reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){
rep->err = errNo; rep->err = errNo;
globalScheduler.execute(&signal, JBA, CMVMI, GSN_DISCONNECT_REP); globalScheduler.execute(&signal, JBA, CMVMI, GSN_DISCONNECT_REP);
DBUG_VOID_RETURN;
} }
void void
......
...@@ -42,6 +42,16 @@ struct NodeReceiverGroup { ...@@ -42,6 +42,16 @@ struct NodeReceiverGroup {
NodeBitmask m_nodes; NodeBitmask m_nodes;
}; };
template <unsigned T> struct SignalT
{
SignalHeader header;
SegmentedSectionPtr m_sectionPtr[3];
union {
Uint32 theData[T];
Uint64 dummyAlign;
};
};
/** /**
* class used for passing argumentes to blocks * class used for passing argumentes to blocks
*/ */
......
...@@ -150,7 +150,6 @@ ConfigInfo::m_SectionRules[] = { ...@@ -150,7 +150,6 @@ ConfigInfo::m_SectionRules[] = {
{ "TCP", fixPortNumber, 0 }, // has to come after fixHostName { "TCP", fixPortNumber, 0 }, // has to come after fixHostName
{ "SHM", fixPortNumber, 0 }, // has to come after fixHostName { "SHM", fixPortNumber, 0 }, // has to come after fixHostName
{ "SCI", fixPortNumber, 0 }, // has to come after fixHostName { "SCI", fixPortNumber, 0 }, // has to come after fixHostName
{ "SHM", fixShmKey, 0 },
/** /**
* fixExtConnection must be after fixNodeId * fixExtConnection must be after fixNodeId
...@@ -164,6 +163,8 @@ ConfigInfo::m_SectionRules[] = { ...@@ -164,6 +163,8 @@ ConfigInfo::m_SectionRules[] = {
{ "*", fixDepricated, 0 }, { "*", fixDepricated, 0 },
{ "*", applyDefaultValues, "system" }, { "*", applyDefaultValues, "system" },
{ "SHM", fixShmKey, 0 }, // has to come after apply default values
{ DB_TOKEN, checkLocalhostHostnameMix, 0 }, { DB_TOKEN, checkLocalhostHostnameMix, 0 },
{ API_TOKEN, checkLocalhostHostnameMix, 0 }, { API_TOKEN, checkLocalhostHostnameMix, 0 },
{ MGM_TOKEN, checkLocalhostHostnameMix, 0 }, { MGM_TOKEN, checkLocalhostHostnameMix, 0 },
...@@ -1798,7 +1799,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1798,7 +1799,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
ConfigInfo::CI_USED, ConfigInfo::CI_USED,
false, false,
ConfigInfo::CI_INT, ConfigInfo::CI_INT,
"0", UNDEFINED,
"0", "0",
STR_VALUE(MAX_INT_RNIL) }, STR_VALUE(MAX_INT_RNIL) },
......
...@@ -63,13 +63,16 @@ TransporterFacade* TransporterFacade::theFacadeInstance = NULL; ...@@ -63,13 +63,16 @@ TransporterFacade* TransporterFacade::theFacadeInstance = NULL;
*****************************************************************************/ *****************************************************************************/
void void
reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode){ reportError(void * callbackObj, NodeId nodeId,
TransporterError errorCode, const char *info)
{
#ifdef REPORT_TRANSPORTER #ifdef REPORT_TRANSPORTER
ndbout_c("REPORT_TRANSP: reportError (nodeId=%d, errorCode=%d)", ndbout_c("REPORT_TRANSP: reportError (nodeId=%d, errorCode=%d) %s",
(int)nodeId, (int)errorCode); (int)nodeId, (int)errorCode, info ? info : "");
#endif #endif
if(errorCode & 0x8000) { if(errorCode & TE_DO_DISCONNECT) {
ndbout_c("reportError (%d, %d)\n", (int)nodeId, (int)errorCode); ndbout_c("reportError (%d, %d) %s", (int)nodeId, (int)errorCode,
info ? info : "");
((TransporterFacade*)(callbackObj))->doDisconnect(nodeId); ((TransporterFacade*)(callbackObj))->doDisconnect(nodeId);
} }
} }
......
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