Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions

void Log_Writer::CheckForLogSaveAndSavepoint ( tgg00_TransContext &  trans  ) 

Triggers the log save component if enough pages for log save available. This is called by the TimeOut task.

Parameters:
trans [in/out]

Definition at line 564 of file Log_Writer.cpp.

References Kernel_DateTime::DetermineTime(), Log_Volume::GetAutosaveDistance(), Log_RawDeviceIterator::GetBeginOffset(), Kernel_DateTime::GetDate(), Log_RawDeviceIterator::GetDistanceFrom(), Log_RawDeviceIterator::GetDistanceTo(), GetIOSequenceNo(), Kernel_DateTime::GetTime(), SAPDB_Invalidatable< T, InvalidValue >::IsInvalid(), SAPDB_Invalidatable< T, InvalidValue >::IsValid(), Log_IOSequenceNo::LeftIsYounger(), LogVolume_Trace, m_ArchiveLog, m_LogInfoPage, m_LogUsageEvents, m_WriteIterator, Kernel_DateTime::OlderThan(), Log_InfoPage::ReadOldestKnownIOSequenceNo(), Log_InfoPage::ReadOldestNotSavedOffset(), Log_Savepoint::StartSavepoint(), UsedPages(), UserLogSize(), and Kernel_EventSet::Watch().

Referenced by Log_Volume::CheckForLogSaveAndSavepoint().

{
    // PTS 1117895 UH 2002-10-21 now called by timeout task
    
    SAPDBTRACE_METHOD_DEBUG ("Log_Writer::CheckForLogSaveAndSavepoint", LogVolume_Trace, 5);
    
    //
    // This is called by the timeout task !!
    //
    
    // reading dirty - autosave task may run parallel and change these values
    const Log_RawDeviceIterator copiedWriterIterator = m_WriteIterator;
    const Log_RawDeviceOffset   oldestNotSavedOffset =
                                 m_LogInfoPage.ReadOldestNotSavedOffset().IsValid()
                                 ? m_LogInfoPage.ReadOldestNotSavedOffset()
                                 : copiedWriterIterator.GetBeginOffset();
    const Log_DeviceBlockCount  notsaveddist         = copiedWriterIterator.GetDistanceFrom(oldestNotSavedOffset);
    const SAPDB_UInt            autosaveDistance     = m_ArchiveLog->GetAutosaveDistance();

    if ( notsaveddist >= autosaveDistance ) // PTS 1113361 mb 2002-01-11
    {
        if ( k38is_on_autosave (trans, false) && trans.trError_gg00 == e_ok )
            k38trigger_autosave (trans, false);
    }

    // PTS 1124876 UH 2003-10-23
    // rewritten without usage of percentage values
    // added Eventhandling
    
    const Log_DeviceBlockCount logsize   = UserLogSize();
    const Log_DeviceBlockCount usedPages = UsedPages();

    m_LogUsageEvents.Watch(usedPages, false);

    // check if a savepoint has to be written

    if (usedPages * 3 > logsize * 2) // usedPages > 2/3 logsize
    {
        Log_RawDeviceOffset startOffset = k57restartrec->rstLastSavept_kb00().svpStartOffset_kb00;

        if ( startOffset.IsInvalid() )
            startOffset = copiedWriterIterator.GetBeginOffset();
            
        if ( copiedWriterIterator.GetDistanceTo(startOffset) * 3  < logsize )
        {
            Log_SavepointManager.StartSavepoint (trans, Log_SVPReasonLogWriter);
            return;
        }
    }

    // if any log was written but not as much as checked before
    // then check if the time defined in RESTART_TIME is reached since last savepoint
    // GetIOSequenceNo() returns the NEXT iosequence which is to be used.
    // writerIOseq - 1 == svpIOseq => nothing was written to the log.

    if ( Log_IOSequenceNo::LeftIsYounger (GetIOSequenceNo(),
                                          k57restartrec->rstLastSavept_kb00().svpIOsequence_kb00
                                                          + 1 + MIN_IOSEQUENCES_BEFORE_SAVEPOINT,
                                          m_LogInfoPage.ReadOldestKnownIOSequenceNo()))
    {
        Kernel_DateTime currentDateTime;
        currentDateTime.DetermineTime();
        
        if ( Kernel_DateTime::OlderThan( k57restartrec->rstLastSavept_kb00().svpDate_kb00,
                                         k57restartrec->rstLastSavept_kb00().svpTime_kb00
                                         + g01restart_time,
                                         currentDateTime.GetDate(),
                                         currentDateTime.GetTime()))
        {
            Log_SavepointManager.StartSavepoint (trans, Log_SVPReasonTime);
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index