Home Forums SQL Server 2008 T-SQL (SS2K8) Need Minimally Logged Operation to Cause Checkpoint! RE: Need Minimally Logged Operation to Cause Checkpoint!

  • ScottPletcher (4/5/2013)


    GilaMonster (4/5/2013)

    Any data modification that is minimally logged has to be written to the data file before the transaction completes

    I don't think that's true. If it is, it violates the write-ahead-logging model, which SQL Server uses; only log records should have to be hardened for a transaction to complete, not data blocks.

    It does not violate write-ahead logging. Write-ahead logging requires that the log records are written to disk before the data pages that they represent, it does not say anything about the timing between the data pages being written and the end of the transaction. In both minimally and fully logged operations, the log records are hardened on disk before the data pages are written back to the data file.

    The difference in terms of writing is that in a fully logged operation, the data changes can be written at any point after the log records, before or after the transaction is committed, because the log records fully describe the changes and hence the change can be redone from just the log records.

    In a minimally logged operation, the data changes are written to disk after the log records and before the transaction is considered committed because the log records do not fully describe the change, there's only enough logging for undo operations (the very definition of minimally logged) and hence redo is not possible. As such, the changes must be hardened to disk before the commit is complete to ensure durability.

    You can see why if you consider the potential scenario of a crash the millisecond after a bulk operation has committed. If the data changes were not required to be written to disk prior to the commit of the transaction then such a crash could leave a minimally logged operation with the log records describing the change hardened in the log file but the changes data pages not on disk. Since the definition of minimally logged is 'enough logging for undo, not for redo', in such a case SQL would not be able to replay that bulk operation as part of crash recovery and would be required to mark that database as suspect (inconsistent). This obviously is not an acceptable option.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass