Пример #1
0
NA_EIDPROC
void NAAssert(char * condition, char * file_, Int32 line_)
{
#if (defined (NA_LINUX) && defined (__EID))
assert_botch_in_eid(file_, line_, condition);
#endif // NA_LINUX & __EID
}
Пример #2
0
void assert_botch_abend( const char *f, Int32 l, const char * m, const char *c)
{
#ifndef __EID
  NAAssertMutexLock(); // Assure "termination synchronization"
  int pid = (int) getpid();

  // get thread id for SeaMonster reader thread or other future
  // executor threads
  int tid = (int) syscall(__NR_gettid);

  Lng32 *tidPtr = tid == pid ? NULL : (Lng32*)&tid;
  if (tid == NAAssertMutexExTid)
    releaseRTSSemaphore(); // Semaphore is released on by main executor thread
  // log the message to the event log
  SQLMXLoggingArea::logSQLMXAssertionFailureEvent(f, l, m, c, tidPtr); // Any executor thread can log a failure

  // Log the message to stderr. On Linux stderr is mapped to a file
  // under $MY_SQROOT/logs and our output will be prefixed with a
  // timestamp and process ID.
  cerr << "Executor assertion failure in file " << f
       << " on line " << l << '\n';
  cerr << "Message: " << m << endl << flush;

#ifdef _DEBUG
  // If debug code, log the message again to the terminal
  char timeString[40] = "";
  time_t tm = time(0);
  ctime_r(&tm, timeString);
  printf("*** EXECUTOR ASSERTION FAILURE\n");
  printf("*** Time: %s", timeString);
  printf("*** Process: %d\n", pid);
  if (tid != pid)
    printf("*** Thread ID: %d\n", tid);
  printf("*** File: %s\n", f);
  printf("*** Line: %d\n", (int) l);
  if (c)
    printf("*** Condition: %s\n", c);
  printf("*** Message: %s\n", m);
  fflush(stdout);
#endif // _DEBUG

  // Cleanup the shared segment since the registered atexit function
  // will not be called
  char *envvar;
  envvar = getenv("SQL_LOOP_ON_ASSERT");
  if (envvar && *envvar == '1')
  {
    while (*envvar == '1')
          sleep(10);
  }
#ifndef _DEBUG
  char *abortOnError = getenv("ABORT_ON_ERROR");
  NAString fileName(f);
  if (abortOnError != NULL)
     abort();
  else if(((int)fileName.index("/optimizer/")) > -1 )
  {
    //throw exception if ABORT is called from optimizer dir
    AssertException(m, f, l).throwException();
  }
  else
#endif
    abort();
#else
  assert_botch_in_eid(f, l, m);
#endif
}