// PD_TRACE_DECLARE_FUNCTION ( SDB__DMSSU_TOTALFREEPAGES, "_dmsStorageUnit::totalFreePages" )
   INT64 _dmsStorageUnit::totalFreePages ( UINT32 type ) const
   {
      INT64 freePages = 0 ;
      PD_TRACE_ENTRY ( SDB__DMSSU_TOTALFREEPAGES ) ;

      if ( !_pDataSu || !_pIndexSu || !_pLobSu )
      {
         goto done ;
      }

      if ( type & DMS_SU_DATA )
      {
         freePages += (INT64)_pDataSu->freePageNum() ;
      }
      if ( type & DMS_SU_INDEX )
      {
         freePages += (INT64)_pIndexSu->freePageNum() ;
      }
      if ( ( type & DMS_SU_LOB ) && _pLobSu->isOpened() )
      {
         freePages += (INT64)_pLobSu->freePageNum() ;
      }

   done:
      PD_TRACE1 ( SDB__DMSSU_TOTALFREEPAGES,
                  PD_PACK_INT ( freePages ) ) ;
      PD_TRACE_EXIT ( SDB__DMSSU_TOTALFREEPAGES ) ;
      return freePages ;
   }
Exemple #2
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__IXMINXCB_TRUNC, "_ixmIndexCB::truncate" )
   INT32 _ixmIndexCB::truncate ( BOOLEAN removeRoot )
   {
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY ( SDB__IXMINXCB_TRUNC );
      PD_TRACE1 ( SDB__IXMINXCB_TRUNC, PD_PACK_INT(removeRoot) );
      setFlag ( IXM_INDEX_FLAG_TRUNCATING ) ;
      dmsExtentID root = getRoot() ;
      if ( DMS_INVALID_EXTENT != root )
      {
         BOOLEAN valid = TRUE ;
         ixmExtent rootExtent ( root, _pIndexSu ) ;
         rootExtent.truncate ( this, DMS_INVALID_EXTENT, valid ) ;
         if ( valid && removeRoot )
         {
            UINT16 mbID = rootExtent.getMBID() ;
            UINT16 freeSize = rootExtent.getFreeSize() ;
            rc = freeExtent ( root ) ;
            if ( rc )
            {
               PD_LOG ( PDERROR, "Failed to free extent %d", root ) ;
               goto error ;
            }
            _pIndexSu->decStatFreeSpace( mbID, freeSize ) ;
         }
      }
      setFlag ( IXM_INDEX_FLAG_NORMAL ) ;

   done :
      scanExtLID ( DMS_INVALID_EXTENT ) ;
      PD_TRACE_EXITRC ( SDB__IXMINXCB_TRUNC, rc );
      return rc ;
   error :
      setFlag ( IXM_INDEX_FLAG_INVALID ) ;
      goto done ;
   }
Exemple #3
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB_PMDCTRLHND, "pmdCtrlHandler" )
   BOOL pmdCtrlHandler( DWORD fdwCtrlType )
   {
      BOOLEAN ret = FALSE ;
      PD_TRACE_ENTRY ( SDB_PMDCTRLHND );
      switch( fdwCtrlType )
      {
      case CTRL_C_EVENT:
         printf( "Ctrl-C event\n\n" ) ;
         pmdGetSysInfo()->_quitFlag = TRUE ;
         if ( pmdGetSysInfo()->_pQuitFunc )
         {
            (*pmdGetSysInfo()->_pQuitFunc)() ;
         }
         Beep( 750, 300 );
         ret = TRUE ;
         goto done ;

      case CTRL_CLOSE_EVENT:
         Beep( 600, 200 );
         printf( "Ctrl-Close event\n\n" ) ;
         ret = TRUE ;
         goto done ;

      case CTRL_BREAK_EVENT:
         Beep( 900, 200 );
         printf( "Ctrl-Break event\n\n" ) ;
         ret = FALSE ;
         goto done ;

      case CTRL_LOGOFF_EVENT:
         Beep( 1000, 200 );
         printf( "Ctrl-Logoff event\n\n" ) ;
         ret = FALSE ;
         goto done ;

      case CTRL_SHUTDOWN_EVENT:
         Beep( 750, 500 );
         printf( "Ctrl-Shutdown event\n\n" ) ;
         ret = FALSE ;
         goto done ;

      default:
         ret = FALSE ;
         goto done ;
      }
   done :
      PD_TRACE1 ( SDB_PMDCTRLHND, PD_PACK_INT(ret) ) ;
      PD_TRACE_EXIT ( SDB_PMDCTRLHND ) ;
      return ret ;
   }
Exemple #4
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__PMDEDUCB_ISINT, "_pmdEDUCB::isInterrupted" )
   BOOLEAN _pmdEDUCB::isInterrupted ( BOOLEAN onlyFlag )
   {
      PD_TRACE_ENTRY ( SDB__PMDEDUCB_ISINT );
      BOOLEAN ret = FALSE ;

      if ( !onlyFlag && _isDoRollback )
      {
         goto done;
      }
      if ( _ctrlFlag & EDU_CTRL_INTERRUPTED )
      {
         ret = TRUE ;
         goto done ;
      }
      else if ( !onlyFlag && _pClientSock )
      {
         if ( _pClientSock->isClosed() )
         {
            _ctrlFlag |= ( EDU_CTRL_INTERRUPTED | EDU_CTRL_DISCONNECTED ) ;
            ret = TRUE ;
         }
         else
         {
            INT32 receivedLen ;
            MsgHeader header ;
            INT32 rc = _pClientSock->recv( (CHAR*)&header , sizeof(header),
                                           receivedLen, 0, MSG_PEEK ) ;
            if ( ( rc >= (INT32)sizeof(header)
                   && MSG_BS_DISCONNECT == header.opCode )
                 || SDB_NETWORK_CLOSE == rc || SDB_NETWORK == rc )
            {
               _ctrlFlag |= ( EDU_CTRL_INTERRUPTED | EDU_CTRL_DISCONNECTED ) ;
               ret = TRUE ;
            }
            else if ( rc >= (INT32)sizeof(header) &&
                      ( MSG_BS_INTERRUPTE == header.opCode ||
                        MSG_BS_INTERRUPTE_SELF == header.opCode ) )
            {
               _ctrlFlag |= EDU_CTRL_INTERRUPTED ;
               ret = TRUE ;
            }
         }
      }
   done :
      PD_TRACE1 ( SDB__PMDEDUCB_ISINT, PD_PACK_INT(ret) );
      PD_TRACE_EXIT ( SDB__PMDEDUCB_ISINT );
      return ret ;
   }
   // PD_TRACE_DECLARE_FUNCTION ( SDB__DPSLGWRAPP_CANSYNC, "_dpsLogWrapper::canSync" )
   BOOLEAN _dpsLogWrapper::canSync( BOOLEAN &force ) const
   {
      BOOLEAN needSync = FALSE ;
      force = FALSE ;
      PD_TRACE_ENTRY( SDB__DPSLGWRAPP_CANSYNC ) ;

      if ( !_buf.hasDirty() )
      {
      }
      else if ( _syncRecordNum > 0 && _writeReordNum >= _syncRecordNum )
      {
         PD_LOG( PDDEBUG, "Write record number[%u] more than threshold[%u]",
                 _writeReordNum, _syncRecordNum ) ;
         force = TRUE ;
         needSync = TRUE ;
      }
      else if ( pmdGetTickSpanTime( _lastWriteTick ) < DPS_NO_WRITE_TIME )
      {
      }
      else if ( _syncInterval > 0 )
      {
         ossTimestamp tm ;
         ossGetCurrentTime( tm ) ;
         UINT64 curTime = tm.time * 1000 + tm.microtm / 1000 ;

         if ( curTime - _lastSyncTime >= _syncInterval )
         {
            PD_LOG( PDDEBUG, "Time interval threshold tiggered, "
                    "CurTime:%llu, LastSyncTime:%llu, SyncInterval:%u",
                    curTime, _lastSyncTime, _syncInterval ) ;
            needSync = TRUE ;
         }
      }

      PD_TRACE1 ( SDB__DPSLGWRAPP_CANSYNC, PD_PACK_INT( needSync ) ) ;
      PD_TRACE_EXIT( SDB__DPSLGWRAPP_CANSYNC ) ;
      return needSync ;
   }
   // PD_TRACE_DECLARE_FUNCTION ( SDB_NETMLTRTAGT_ISSUBSESSCONN, "netMultiRouteAgent::isSubSessionConnected" )
   BOOLEAN netMultiRouteAgent::isSubSessionConnected( UINT32 tID,
                                                      const MsgRouteID &ID )
   {
      PD_TRACE_ENTRY ( SDB_NETMLTRTAGT_ISSUBSESSCONN );
      BOOLEAN hasConnected = FALSE;
      CoordSession *pSession = NULL;

      {
         COORD_SESSION_MAP::iterator it;
         ossScopedLock _lock(&_mutex, SHARED) ;
         it = _sessionMap.find( tID );
         if ( it != _sessionMap.end() )
         {
            pSession = it->second ;
         }
      }
      if ( pSession != NULL )
      {
         hasConnected = pSession->isSubsessionConnected( ID );
      }
      PD_TRACE1 ( SDB_NETMLTRTAGT_ISSUBSESSCONN, PD_PACK_INT(hasConnected) );
      PD_TRACE_EXIT ( SDB_NETMLTRTAGT_ISSUBSESSCONN );
      return hasConnected;
   }
Exemple #7
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB_PMDEDUUSERTRAPHNDL, "pmdEDUUserTrapHandler" )
   void pmdEDUUserTrapHandler( OSS_HANDPARMS )
   {
#if defined( SDB_ENGINE )
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY ( SDB_PMDEDUUSERTRAPHNDL );
      oss_edu_data * pEduData = NULL ;
      const CHAR *dumpPath = ossGetTrapExceptionPath () ;
      if ( !dumpPath )
      {
         goto done ;
      }

      pEduData = ossGetThreadEDUData() ;

      if ( NULL == pEduData )
      {
         goto done ;
      }

      if ( OSS_AM_I_INSIDE_SIGNAL_HANDLER( pEduData ) )
      {
         goto done ;
      }
      OSS_ENTER_SIGNAL_HANDLER( pEduData ) ;

      if ( signum == OSS_STACK_DUMP_SIGNAL )
      {
         PD_LOG ( PDEVENT, "Signal %d is received, "
                  "prepare to dump stack for all threads", signum ) ;
         std::set<pthread_t>::iterator it ;
         std::set<pthread_t> tidList ;
         pmdGetKRCB()->getEDUMgr()->getEDUThreadID ( tidList ) ;
         for ( it = tidList.begin(); it != tidList.end(); ++it )
         {
            if ( 0 == (*it) )
            {
               continue ;
            }
            rc = ossPThreadKill ( (*it), OSS_STACK_DUMP_SIGNAL_INTERNAL ) ;
            if ( rc )
            {
               PD_LOG ( PDWARNING, "Failed to send signal %d to thread %llu, "
                        "errno = %d", OSS_STACK_DUMP_SIGNAL_INTERNAL,
                        (*it), ossGetLastError() ) ;
            }
         }
         ossMemTrace ( dumpPath ) ;
      }
      else if ( signum == OSS_STACK_DUMP_SIGNAL_INTERNAL )
      {
         PD_LOG ( PDEVENT, "Signal %d is received, "
                  "prepare to dump stack for %u:%u", signum,
                  ossGetCurrentProcessID(),
                  ossGetCurrentThreadID() ) ;
         ossStackTrace( OSS_HANDARGS, dumpPath ) ;
      }
      else
      {
         PD_LOG ( PDWARNING, "Unexpected signal is received: %d",
                  signum ) ;
      }
      OSS_LEAVE_SIGNAL_HANDLER( pEduData ) ;
   done :
      PD_TRACE1 ( SDB_PMDEDUUSERTRAPHNDL, PD_PACK_INT(rc) );
      PD_TRACE_EXIT ( SDB_PMDEDUUSERTRAPHNDL ) ;
#endif // SDB_ENGINE
      return ;
   }