On 4/19/15, Joe Pasquariello <joep at fenway.com> wrote:
> Some users of my application have their servers in remote locations that
> lose power. They have UPS backup, but the battery runs down and the
> computers will suddenly stop. When power returns and the application
> starts, the SQLITE database is sometimes corrupt. The vast majority of
> writes to the database are to a table that could be TEMPORARY, but is
> currently not. If that table was created as TEMPORARY, and it was in
> MEMORY, as opposed to FILE, would the likelihood of corruption on
> restart be reduced?

Yes.  Corruption is only possible if power is lost in the middle of a
COMMIT and either you have PRAGMA synchronous=off, or your OS/hardware
combination is not doing real fsync()s when requested.  So if you
dramatically reduce the number of COMMITs you also reduce the number
of windows of vulnerability.

> If not, is there another change (schema or
> otherwise) that would help?
>

Using WAL mode will help, if that is possible.  Your phrase "remote
servers" is not exactly clear to me?  Are they using a network
filesystem?
-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to