Commit a47ee867 authored by unknown's avatar unknown
Browse files

Bug#19203, Different error reports for similar cases - unable allocate memory


storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp:
  if malloc failed, it will show the parameter's name
storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp:
  if malloc failed, it will show the parameter's name
storage/ndb/src/kernel/vm/ArrayPool.hpp:
  reduce err message, or else some of it will be cut
storage/ndb/src/kernel/vm/SimulatedBlock.cpp:
  add the feature which it can display the parameter's name if malloc failed
storage/ndb/src/kernel/vm/SimulatedBlock.hpp:
  add an input argument which is the ID of a parameter
parent 479ffe15
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ void Dbacc::initRecords()
  page8 = (Page8*)allocRecord("Page8",
			      sizeof(Page8), 
			      cpagesize,
			      false);
			      false,
            CFG_DB_INDEX_MEM);

  operationrec = (Operationrec*)allocRecord("Operationrec",
					    sizeof(Operationrec),
+5 −2
Original line number Diff line number Diff line
@@ -342,6 +342,7 @@ void Dbtup::initRecords()
{
  unsigned i;
  Uint32 tmp;
  Uint32 tmp1 = 0;
  const ndb_mgm_configuration_iterator * p = 
    m_ctx.m_config.getOwnConfigIterator();
  ndbrequire(p != 0);
@@ -349,7 +350,7 @@ void Dbtup::initRecords()
  ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE, &tmp));

  // Records with dynamic sizes
  Page* ptr =(Page*)allocRecord("Page", sizeof(Page), tmp, false);
  Page* ptr =(Page*)allocRecord("Page", sizeof(Page), tmp, false, CFG_DB_DATA_MEM);
  c_page_pool.set(ptr, tmp);
  
  attrbufrec = (Attrbufrec*)allocRecord("Attrbufrec", 
@@ -373,7 +374,9 @@ void Dbtup::initRecords()
						  cnoOfTabDescrRec);

  ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_OP_RECS, &tmp));
  c_operation_pool.setSize(tmp);
  ndb_mgm_get_int_parameter(p, CFG_DB_NO_LOCAL_OPS, &tmp1);
  c_operation_pool.setSize(tmp, false, true, true, 
      tmp1 == 0 ? CFG_DB_NO_OPS : CFG_DB_NO_LOCAL_OPS);
  
  pageRange = (PageRange*)allocRecord("PageRange",
				      sizeof(PageRange), 
+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ ArrayPool<T>::setSize(Uint32 noOfElements,

      if(0 != paramId && 0 == ndb_mgm_get_db_parameter_info(paramId, &param_info, &size)) {
        BaseString::snprintf(errmsg, sizeof(errmsg), 
                "ArrayPool<T>::setSize malloc parameter %s failed", param_info.m_name);
                "Malloc memory for %s failed", param_info.m_name);
      }

      ErrorReporter::handleAssert(errmsg,
+11 −3
Original line number Diff line number Diff line
@@ -657,7 +657,7 @@ SimulatedBlock::getBatSize(Uint16 blockNo){
}

void* 
SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear) 
SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, Uint32 paramId) 
{

  void * p = NULL;
@@ -678,8 +678,16 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear)
    if (p == NULL){
      char buf1[255];
      char buf2[255];
      struct ndb_mgm_param_info param_info;
      size_t size = sizeof(ndb_mgm_param_info);

      if(0 != paramId && 0 == ndb_mgm_get_db_parameter_info(paramId, &param_info, &size)) {
        BaseString::snprintf(buf1, sizeof(buf1), "%s could not allocate memory for parameter %s", 
	         getBlockName(number()), param_info.m_name);
      } else {
        BaseString::snprintf(buf1, sizeof(buf1), "%s could not allocate memory for %s", 
	         getBlockName(number()), type);
      }
      BaseString::snprintf(buf2, sizeof(buf2), "Requested: %ux%u = %llu bytes", 
	       (Uint32)s, (Uint32)n, (Uint64)real_size);
      ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, buf1, buf2);
+1 −1
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ protected:
   * Allocates memory for the datastructures where ndb keeps the data
   *
   */
  void* allocRecord(const char * type, size_t s, size_t n, bool clear = true);
  void* allocRecord(const char * type, size_t s, size_t n, bool clear = true, Uint32 paramId = 0);
  
  /**
   * Deallocate record