I have a long-running application that is written in a mixture of C and C ++ which is the data in SQLite Stores.
I believe that committed statistics will be available (excluding mechanical failure) and latent data will not be there, it is not clear to me that what I can do with such a middle state.
I get the number of inserts in a large one transaction and then commit it when there is an error on a given statement, then I can schedule it to try at some point in the future. It seems that some can prevent errors in my transactions (which would be accurate if this is true).
A big problem occurs when my commitment fails. Currently, I continue to try it again until it does not work. I hope that whatever can be the reason for my failure, one rollback can fail very well.
What is the recommended mechanism to deal with the error in such a situation?
At COMMIT, if you see a SQLITE_BUSY error, then you should come back with a commit . it might work. Better yet, install a busy-handler callback to handle SQLITE_BUSY.
Another reason a committe may fail is a deferred foreign key violation. If this happens then you can fix the FK violation and then COMMIT, although it is difficult to see an unmanned application.
You should probably leave other errors and rollback the transaction.
If there is an IO or OOM error, then the current transaction may be withdrawn. The reason for this is that some IO or OOM errors leave SQLite indefinitely whether its internal data structure actually matches the disk or not. If we wanted to proceed to this point then the database could be corrupted.
You can test whether the transaction is back by SQLite using the sqlite3_get_autocommit () API or not
If IO or OOM error occurs during COM IIT, transactions may still be committed. It can happen, for example, if the user has to move the memory card out of a camera such as the transaction is committed, reading the DB and making the data consistently in the media without checking at the application level is probably not possible.
Comments
Post a Comment