sqlite3 - SQLite VACUUM in DB opened from multiple processes -


i’ve 2 questions sqlite vacuum (and possibly wal):

• if multiple processes have db open, sql statements in processes need finalized vacuum succeed?

• why vacuum sometime not have effect (no space reclaimed) sqlite return sqlite3_ok?

a bit more details problem:

i’ve database in wal mode accessed 2 processes. @ point, user has choice of dropping data database. because database can opened multiple processes, delete records , run vacuum reclaim disk space (instead of closing connection , deleting file).

the problem if 2 processes have db connection opened, vacuum 1 of processes returns ok, not reclaim space really.

i think happens vacuum won’t succeed till there’s outstanding sql statement process. problem not want make 2 processes aware of each other.

what considering doing vacuum both processes, whichever closes connection last (upon user request drop data), takes care of space reclamation. considering auto_vacuum (i aware of limitations, deletes not frequent on database.

the documentation says:

a vacuum fail if there open transaction, or if there 1 or more active sql statements when run.

just other kind of database modification, writable transaction requires no other read or write transaction active; requires statements reset or finalized.

when in wal mode, write transaction not blocked other read transactions, requires old data kept. should initiate truncate checkpoint in addition vacuum.


the easiest way handle not run vacuum @ all; free space reused later.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -