![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
We can do something similar in sybase where we say ok, I don't care what has been added to the transaction log but not committed, I'm happy with my data in the binary tree, just forget logs and bring online the current data. Is this possible or I am relegated to losing my db files? |
#3
| |||
| |||
|
|
We can do something similar in sybase where we say ok, I don't care what has been added to the transaction log but not committed, I'm happy with my data in the binary tree, just forget logs and bring online the current data. Is this possible or I am relegated to losing my db files? When BDB says 'recovery' it specifically means applying txn log records to bring a database into a consistent state. So you can't run recovery because you no longer have all the necessary log records (BTW in passing I wonder if this is because you're not taking checkpoints often enough, or not at all ?). But...you can attempt to regain the data that remains in the data files (essentially the exact same process as sybase offers). Let's consider what exactly you have in those data files: pages that happened to have been written to disk before the application exited. If you are lucky, the files will not contain any inconsistencies, either at the BDB metadata level, nor at the application data semantics level. So the first thing to do is to check for inconsistencies at the BDB level. To do this run db_verify on the database. This tool will tell you if the files are consistent (or not) from a b-tree and page level perspective. If they are, proceed to the next step. If not then your only option is to run db_dump on the files to extract the set of readable keys. Then run db_load with the resulting flat files to re-build new data files that are not broken. This process may loose some data but unless you want to break out your hex editor it was lost anyway. Once you have a set of files that db_verify says are ok you then have to consider if the data is consistent from the application's perspective. This is something that only you can do since it's your application. An example would be where a secondary index is out of sync with the primary index. Check for and fix any such errors (re-loading from only the primary index may be an option here). Finally delete any log files and the region files (__xxx files) and you should be able to run db_recover (which won't actually do any recovery as there are no log files). Now you can re-start your application. If you are sure that the data files are already consistent (e.g. you know for sure that the application was shut down gracefully and you simply lost some log files), then it's ok to just delete the log and region files and re-start. |
![]() |
| Thread Tools | |
| Display Modes | |
| |