cancel
Showing results for 
Search instead for 
Did you mean: 

How to check the need of recovery before starting a DB

MCMartin
Participant
3,559

Database recovery can be a time consuming task, so does any tool exists, which give you information about the need to recover and also possibly about the extent of recovery which will be performed, like last checkpoint in relation to transaction logfile or so, without starting the database?

Accepted Solutions (1)

Accepted Solutions (1)

jeff_albion
Product and Topic Expert
Product and Topic Expert

Attempting to start the database in read-only mode will tell you this information:

dbsrvX <database.db> -r

**Error** - Database cannot be started -- <filename> cannot be started read-only because it requires recovery.

... but you will end up starting the database in read-only mode if it doesn't require recovery.

Answers (1)

Answers (1)

johnsmirnios
Advisor
Advisor

If you try to disable the transaction log (dblog -n foo.db) for a database that requires recovery, it will fail with the message "Database quit abnormally last time it was used. Database recovery must be performed before proceeding."

However, you MUST remember to enable the log again if you successfully disable it!

Jeff's suggestion of using read-only mode is probably safer.

VolkerBarth
Contributor
0 Kudos

So there's no "database flag" (in the header page) indicating that - in a way, say a new DBTools API function could interpret that?

(Note: I don't ask for such a suggestion, it's just out of curiosity...)

johnsmirnios
Advisor
Advisor

There's no API available to make that determination. It actually gets a bit more complex than I originally thought too. A successful invocation of "dblog -n foo.db" really means "the transaction log is not needed for recovery". There are at least three separate indications of "needs recovery": checkpoint log, undo log(s), and redo log. I believe the read-only mode will check all three.