Corrupt transaction log - Build a new ASE transaction log

July 29, 2009

Corrupt transaction log; Build a new ASE transaction log with dbcc rebuild_log

In some cases it is necessary to rebuild the ASE transaction log.

Sybase Technical Support states that this is extremely dangerous. It may cause potential database corruption if the system fails while the timestamp rolls over.

  • dump the database first. If "dbcc rebuild_log" corrupts the database you can give it a second try.
  • login to the ASE
  • run
    SELECT count(*) FROM db_name_with_corrupt_log..syslogs

    the result is an int-value higher than 1.

  • configure the ASE to allow updates on systemtables:

    sp_configure "allow updates",1
  • identify the "status" from sysdatabases with:
    SELECT STATUS FROM master..sysdatabases WHERE name = "db_name_with_corrupt_log"

    The result is "your_db_status" which is a int-value. Save it.

  • set the status of "db_name_with_corrupt_log" to "bypass recovery mode" (-32786).
    begin tran
    go
    UPDATE sysdatabases SET STATUS = -32768 WHERE name = "db_name_with_corrupt_log"
    go
    commit tran
    go
  • if the update was successfull shutdown and reboot the ASE
  • than run first
    dbcc rebuild_log (db_name_with_corrupt_log, 0, 0)
  • and afterwards
    dbcc rebuild_log (db_name_with_corrupt_log, 1, 1)
  • USE db_name_with_corrupt_log
  • check the syslogs of db_name_with_corrupt_log. It should be 1.
    SELECT count(*) FROM syslogs
  • set the status in sysdatabases back to the original one. Run:
    begin tran
    go
    UPDATE sysdatabases SET STATUS = <your_db_status> WHERE name = "db_name_with_corrupt_log"
    go
    commit tran
    go
  • reboot the ASE again.
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org