Commit c9f8b7b4 authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -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));
+1 −1
Original line number Diff line number Diff line
@@ -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 },
+2 −0
Original line number Diff line number Diff line
@@ -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);    
+6 −1
Original line number Diff line number Diff line
@@ -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)
+41 −17
Original line number Diff line number Diff line
@@ -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,9 +1356,34 @@ 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)
  {
    goto send_report;
  }
  return;

send_report:
  Uint32 data[8];
  data[0]= NDB_LE_EventBufferStatus;
  data[1]= m_total_alloc-m_free_data_sz;
@@ -1373,7 +1398,6 @@ NdbEventBuffer::reportStatus()
  assert(m_total_alloc >= m_free_data_sz);
#endif
}
}

template class Vector<Gci_container>;
template class Vector<NdbEventBuffer::EventBufData_chunk*>;
Loading