Commit c9f8b7b4 authored by unknown's avatar unknown

fix error handling if thread creation fails in ndbd

  make sure ndb threads are not started with too small stacksize (which results in default, much too big, stack size to be used)
  moved initialization of ndbd fs block first to ensure that it gets enough space for allocation of file system thread stacks
  changed event buffer reporting in ndb to occur not as often
  corrected the bank application
  corrected output from run-test make-config.sh


storage/ndb/src/common/portlib/NdbThread.c:
    fix error handling if thread creation fails in ndbd
    make sure ndb threads are not started with too small stacksize (which results in default, much too big, stack size to be used)
storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp:
  moved initialization of ndbd fs block first to ensure that it gets enough space for allocation of file system thread stacks
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp:
    fix error handling if thread creation fails in ndbd
storage/ndb/src/ndbapi/Ndb.cpp:
  changed event buffer reporting in ndb to occur not as often
storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp:
  changed event buffer reporting in ndb to occur not as often
storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp:
  changed event buffer reporting in ndb to occur not as often
storage/ndb/test/ndbapi/bank/BankLoad.cpp:
  corrected the bank application
storage/ndb/test/run-test/make-config.sh:
  corrected output from run-test make-config.sh
parent 36dd2cf6
...@@ -115,10 +115,13 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, ...@@ -115,10 +115,13 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
pthread_attr_init(&thread_attr); pthread_attr_init(&thread_attr);
#if (SIZEOF_CHARP == 8) #if (SIZEOF_CHARP == 8)
pthread_attr_setstacksize(&thread_attr, 2*thread_stack_size); thread_stack_size *= 2;
#else #endif
pthread_attr_setstacksize(&thread_attr, thread_stack_size); #ifdef PTHREAD_STACK_MIN
if (thread_stack_size < PTHREAD_STACK_MIN)
thread_stack_size = PTHREAD_STACK_MIN;
#endif #endif
pthread_attr_setstacksize(&thread_attr, thread_stack_size);
#ifdef USE_PTHREAD_EXTRAS #ifdef USE_PTHREAD_EXTRAS
/* Guard stack overflow with a 2k databuffer */ /* Guard stack overflow with a 2k databuffer */
pthread_attr_setguardsize(&thread_attr, 2048); pthread_attr_setguardsize(&thread_attr, 2048);
...@@ -133,7 +136,11 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, ...@@ -133,7 +136,11 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
&thread_attr, &thread_attr,
ndb_thread_wrapper, ndb_thread_wrapper,
tmpThread); tmpThread);
assert(result==0); if (result != 0)
{
NdbMem_Free((char *)tmpThread);
tmpThread = 0;
}
pthread_attr_destroy(&thread_attr); pthread_attr_destroy(&thread_attr);
DBUG_PRINT("exit",("ret: %lx", tmpThread)); DBUG_PRINT("exit",("ret: %lx", tmpThread));
......
...@@ -66,13 +66,13 @@ struct BlockInfo { ...@@ -66,13 +66,13 @@ struct BlockInfo {
}; };
static BlockInfo ALL_BLOCKS[] = { static BlockInfo ALL_BLOCKS[] = {
{ NDBFS_REF, 0 , 2000, 2999 },
{ DBTC_REF, 1 , 8000, 8035 }, { DBTC_REF, 1 , 8000, 8035 },
{ DBDIH_REF, 1 , 7000, 7173 }, { DBDIH_REF, 1 , 7000, 7173 },
{ DBLQH_REF, 1 , 5000, 5030 }, { DBLQH_REF, 1 , 5000, 5030 },
{ DBACC_REF, 1 , 3000, 3999 }, { DBACC_REF, 1 , 3000, 3999 },
{ DBTUP_REF, 1 , 4000, 4007 }, { DBTUP_REF, 1 , 4000, 4007 },
{ DBDICT_REF, 1 , 6000, 6003 }, { DBDICT_REF, 1 , 6000, 6003 },
{ NDBFS_REF, 0 , 2000, 2999 },
{ NDBCNTR_REF, 0 , 1000, 1999 }, { NDBCNTR_REF, 0 , 1000, 1999 },
{ QMGR_REF, 1 , 1, 999 }, { QMGR_REF, 1 , 1, 999 },
{ CMVMI_REF, 1 , 9000, 9999 }, { CMVMI_REF, 1 , 9000, 9999 },
......
...@@ -122,6 +122,8 @@ AsyncFile::doStart() ...@@ -122,6 +122,8 @@ AsyncFile::doStart()
stackSize, stackSize,
(char*)&buf, (char*)&buf,
NDB_THREAD_PRIO_MEAN); NDB_THREAD_PRIO_MEAN);
if (theThreadPtr == 0)
ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, "","Could not allocate file system thread");
NdbCondition_Wait(theStartConditionPtr, NdbCondition_Wait(theStartConditionPtr,
theStartMutexPtr); theStartMutexPtr);
......
...@@ -1300,7 +1300,12 @@ Uint64 Ndb::getLatestGCI() ...@@ -1300,7 +1300,12 @@ Uint64 Ndb::getLatestGCI()
void Ndb::setReportThreshEventGCISlip(unsigned thresh) void Ndb::setReportThreshEventGCISlip(unsigned thresh)
{ {
theEventBuffer->m_gci_slip_thresh= thresh; if (theEventBuffer->m_free_thresh != thresh)
{
theEventBuffer->m_free_thresh= thresh;
theEventBuffer->m_min_free_thresh= thresh;
theEventBuffer->m_max_free_thresh= 100;
}
} }
void Ndb::setReportThreshEventFreeMem(unsigned thresh) void Ndb::setReportThreshEventFreeMem(unsigned thresh)
......
...@@ -539,6 +539,8 @@ NdbEventBuffer::NdbEventBuffer(Ndb *ndb) : ...@@ -539,6 +539,8 @@ NdbEventBuffer::NdbEventBuffer(Ndb *ndb) :
m_latestGCI(0), m_latestGCI(0),
m_total_alloc(0), m_total_alloc(0),
m_free_thresh(10), m_free_thresh(10),
m_min_free_thresh(10),
m_max_free_thresh(100),
m_gci_slip_thresh(3), m_gci_slip_thresh(3),
m_dropped_ev_op(0), m_dropped_ev_op(0),
m_active_op_count(0) m_active_op_count(0)
...@@ -635,8 +637,6 @@ int NdbEventBuffer::expand(unsigned sz) ...@@ -635,8 +637,6 @@ int NdbEventBuffer::expand(unsigned sz)
EventBufData_chunk *chunk_data= EventBufData_chunk *chunk_data=
(EventBufData_chunk *)NdbMem_Allocate(alloc_size); (EventBufData_chunk *)NdbMem_Allocate(alloc_size);
m_total_alloc+= alloc_size;
chunk_data->sz= sz; chunk_data->sz= sz;
m_allocated_data.push_back(chunk_data); m_allocated_data.push_back(chunk_data);
...@@ -902,8 +902,8 @@ NdbEventBuffer::execSUB_GCP_COMPLETE_REP(const SubGcpCompleteRep * const rep) ...@@ -902,8 +902,8 @@ NdbEventBuffer::execSUB_GCP_COMPLETE_REP(const SubGcpCompleteRep * const rep)
assert(bucket->m_data.m_count); assert(bucket->m_data.m_count);
#endif #endif
m_complete_data.m_data.append(bucket->m_data); m_complete_data.m_data.append(bucket->m_data);
reportStatus();
} }
reportStatus();
bzero(bucket, sizeof(Gci_container)); bzero(bucket, sizeof(Gci_container));
bucket->m_gci = gci + ACTIVE_GCI_DIRECTORY_SIZE; bucket->m_gci = gci + ACTIVE_GCI_DIRECTORY_SIZE;
bucket->m_gcp_complete_rep_count = m_system_nodes; bucket->m_gcp_complete_rep_count = m_system_nodes;
...@@ -1356,9 +1356,34 @@ NdbEventBuffer::reportStatus() ...@@ -1356,9 +1356,34 @@ NdbEventBuffer::reportStatus()
else else
apply_gci= latest_gci; apply_gci= latest_gci;
if (100*m_free_data_sz < m_free_thresh*m_total_alloc || if (100*m_free_data_sz < m_min_free_thresh*m_total_alloc &&
latest_gci-apply_gci >= m_gci_slip_thresh) m_total_alloc > 1024*1024)
{
/* report less free buffer than m_free_thresh,
next report when more free than 2 * m_free_thresh
*/
m_min_free_thresh= 0;
m_max_free_thresh= 2 * m_free_thresh;
goto send_report;
}
if (100*m_free_data_sz > m_max_free_thresh*m_total_alloc &&
m_total_alloc > 1024*1024)
{ {
/* report more free than 2 * m_free_thresh
next report when less free than m_free_thresh
*/
m_min_free_thresh= m_free_thresh;
m_max_free_thresh= 100;
goto send_report;
}
if (latest_gci-apply_gci >= m_gci_slip_thresh)
{
goto send_report;
}
return;
send_report:
Uint32 data[8]; Uint32 data[8];
data[0]= NDB_LE_EventBufferStatus; data[0]= NDB_LE_EventBufferStatus;
data[1]= m_total_alloc-m_free_data_sz; data[1]= m_total_alloc-m_free_data_sz;
...@@ -1372,7 +1397,6 @@ NdbEventBuffer::reportStatus() ...@@ -1372,7 +1397,6 @@ NdbEventBuffer::reportStatus()
#ifdef VM_TRACE #ifdef VM_TRACE
assert(m_total_alloc >= m_free_data_sz); assert(m_total_alloc >= m_free_data_sz);
#endif #endif
}
} }
template class Vector<Gci_container>; template class Vector<Gci_container>;
......
...@@ -271,7 +271,7 @@ public: ...@@ -271,7 +271,7 @@ public:
unsigned m_total_alloc; // total allocated memory unsigned m_total_alloc; // total allocated memory
// threshholds to report status // threshholds to report status
unsigned m_free_thresh; unsigned m_free_thresh, m_min_free_thresh, m_max_free_thresh;
unsigned m_gci_slip_thresh; unsigned m_gci_slip_thresh;
NdbError m_error; NdbError m_error;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
struct AccountTypesStruct { struct AccountTypesStruct {
int id; int id;
const char* descr; const char descr[64];
}; };
const AccountTypesStruct accountTypes[] = { const AccountTypesStruct accountTypes[] = {
{ 0, "KASSA"}, { 0, "KASSA"},
......
...@@ -44,7 +44,7 @@ add_proc (){ ...@@ -44,7 +44,7 @@ add_proc (){
;; ;;
mysqld) mysqld)
echo "$proc_no.mysqld" >> $dir_file echo "$proc_no.mysqld" >> $dir_file
echo "[ndb_mgmd]" >> $config_file echo "[mysqld]" >> $config_file
echo "Id: $node_id" >> $config_file echo "Id: $node_id" >> $config_file
echo "HostName: $2" >> $config_file echo "HostName: $2" >> $config_file
node_id=`expr $node_id + 1` node_id=`expr $node_id + 1`
......
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