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
parent 4e666f2f
......@@ -115,10 +115,13 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
pthread_attr_init(&thread_attr);
#if (SIZEOF_CHARP == 8)
pthread_attr_setstacksize(&thread_attr, 2*thread_stack_size);
#else
pthread_attr_setstacksize(&thread_attr, thread_stack_size);
thread_stack_size *= 2;
#endif
#ifdef PTHREAD_STACK_MIN
if (thread_stack_size < PTHREAD_STACK_MIN)
thread_stack_size = PTHREAD_STACK_MIN;
#endif
pthread_attr_setstacksize(&thread_attr, thread_stack_size);
#ifdef USE_PTHREAD_EXTRAS
/* Guard stack overflow with a 2k databuffer */
pthread_attr_setguardsize(&thread_attr, 2048);
......@@ -133,7 +136,11 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
&thread_attr,
ndb_thread_wrapper,
tmpThread);
assert(result==0);
if (result != 0)
{
NdbMem_Free((char *)tmpThread);
tmpThread = 0;
}
pthread_attr_destroy(&thread_attr);
DBUG_PRINT("exit",("ret: %lx", tmpThread));
......
......@@ -66,13 +66,13 @@ struct BlockInfo {
};
static BlockInfo ALL_BLOCKS[] = {
{ NDBFS_REF, 0 , 2000, 2999 },
{ DBTC_REF, 1 , 8000, 8035 },
{ DBDIH_REF, 1 , 7000, 7173 },
{ DBLQH_REF, 1 , 5000, 5030 },
{ DBACC_REF, 1 , 3000, 3999 },
{ DBTUP_REF, 1 , 4000, 4007 },
{ DBDICT_REF, 1 , 6000, 6003 },
{ NDBFS_REF, 0 , 2000, 2999 },
{ NDBCNTR_REF, 0 , 1000, 1999 },
{ QMGR_REF, 1 , 1, 999 },
{ CMVMI_REF, 1 , 9000, 9999 },
......
......@@ -122,6 +122,8 @@ AsyncFile::doStart()
stackSize,
(char*)&buf,
NDB_THREAD_PRIO_MEAN);
if (theThreadPtr == 0)
ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, "","Could not allocate file system thread");
NdbCondition_Wait(theStartConditionPtr,
theStartMutexPtr);
......
......@@ -1300,7 +1300,12 @@ Uint64 Ndb::getLatestGCI()
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)
......
......@@ -539,6 +539,8 @@ NdbEventBuffer::NdbEventBuffer(Ndb *ndb) :
m_latestGCI(0),
m_total_alloc(0),
m_free_thresh(10),
m_min_free_thresh(10),
m_max_free_thresh(100),
m_gci_slip_thresh(3),
m_dropped_ev_op(0),
m_active_op_count(0)
......@@ -635,8 +637,6 @@ int NdbEventBuffer::expand(unsigned sz)
EventBufData_chunk *chunk_data=
(EventBufData_chunk *)NdbMem_Allocate(alloc_size);
m_total_alloc+= alloc_size;
chunk_data->sz= sz;
m_allocated_data.push_back(chunk_data);
......@@ -902,8 +902,8 @@ NdbEventBuffer::execSUB_GCP_COMPLETE_REP(const SubGcpCompleteRep * const rep)
assert(bucket->m_data.m_count);
#endif
m_complete_data.m_data.append(bucket->m_data);
reportStatus();
}
reportStatus();
bzero(bucket, sizeof(Gci_container));
bucket->m_gci = gci + ACTIVE_GCI_DIRECTORY_SIZE;
bucket->m_gcp_complete_rep_count = m_system_nodes;
......@@ -1356,23 +1356,47 @@ NdbEventBuffer::reportStatus()
else
apply_gci= latest_gci;
if (100*m_free_data_sz < m_free_thresh*m_total_alloc ||
latest_gci-apply_gci >= m_gci_slip_thresh)
if (100*m_free_data_sz < m_min_free_thresh*m_total_alloc &&
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)
{
Uint32 data[8];
data[0]= NDB_LE_EventBufferStatus;
data[1]= m_total_alloc-m_free_data_sz;
data[2]= m_total_alloc;
data[3]= 0;
data[4]= apply_gci & ~(Uint32)0;
data[5]= apply_gci >> 32;
data[6]= latest_gci & ~(Uint32)0;
data[7]= latest_gci >> 32;
m_ndb->theImpl->send_event_report(data,8);
goto send_report;
}
return;
send_report:
Uint32 data[8];
data[0]= NDB_LE_EventBufferStatus;
data[1]= m_total_alloc-m_free_data_sz;
data[2]= m_total_alloc;
data[3]= 0;
data[4]= apply_gci & ~(Uint32)0;
data[5]= apply_gci >> 32;
data[6]= latest_gci & ~(Uint32)0;
data[7]= latest_gci >> 32;
m_ndb->theImpl->send_event_report(data,8);
#ifdef VM_TRACE
assert(m_total_alloc >= m_free_data_sz);
assert(m_total_alloc >= m_free_data_sz);
#endif
}
}
template class Vector<Gci_container>;
......
......@@ -271,7 +271,7 @@ public:
unsigned m_total_alloc; // total allocated memory
// 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;
NdbError m_error;
......
......@@ -23,7 +23,7 @@
*/
struct AccountTypesStruct {
int id;
const char* descr;
const char descr[64];
};
const AccountTypesStruct accountTypes[] = {
{ 0, "KASSA"},
......
......@@ -44,7 +44,7 @@ add_proc (){
;;
mysqld)
echo "$proc_no.mysqld" >> $dir_file
echo "[ndb_mgmd]" >> $config_file
echo "[mysqld]" >> $config_file
echo "Id: $node_id" >> $config_file
echo "HostName: $2" >> $config_file
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