Comments (7)
The proposal is to support the periodic VACUUM of the SQLite database managed by rqlite. The feature would work be controlled follows:
- Two new command line flags would be added to
rqlited
, which would allow operators to control the automatic and periodic VACUUM of the SQLite database managed by rqlite:- First command line flag would be
-auto-vacuum-int
and would accept a Go-format time duration string, such as7d
. This would set the interval between VACUUM attempts. If not set, then no automatic VACUUMs are executed on that node. - The second command line flag would be
-auto-vacuum-size
which would specify the minimum size (in bytes) that the SQLite database file must be before a VACUUM is executed. 0 is a valid value to set, and means a VACUUM will be executed every cycle.
- First command line flag would be
The VACUUM flags should be set on every node on the cluster, including read-only nodes, for which VACUUM is required. It will not be necessary to have identical VACUUM settings on each node however.
Each node will persistently store the last time a VACUUM successfully executed, so even if the node is restarted, it will next attempt a VACUUM on schedule.
VACUUM is an IO-intensive operation, and will also require a fair amount of free disk space. Operators should ensure that there is at least 2 times the amount of free disk space as the size of the SQLite database about to be VACUUMed. Writes will also be blocked while a VACUUM operation is taking place. No error will be returned, instead the HTTP API will not respond until the VACUUM has completed, the the pending write request completes.
I may also add a HTTP endpoint that allows a VACUUM to be executed on demand, on that specific node.
from rqlite.
LGTM!
from rqlite.
Some notes for my own use. It appears that when VACUUM is done, only the WAL file is affected. This is as written in the SQLite VACUUM docs. However there is enough ambiguity about whether the main SQLite file in touched too that a full snapshot is the only way to ensure the system is correct. Furthermore, for large VACUUMs, it would be too memory intensive anyway, so full snapshot remains the conservative approach.
from rqlite.
Unit test in #1615 confirms VACUUM introduces uncertainty, so going with the conservative approach of a full snapshot post a VACUUM makes sense.
from rqlite.
Update - unit test has been fixed, a full snapshot may not actually be necessary. More testing required.
from rqlite.
@jmordica -- after doing more research, I'd like to propose the following change: instead of simply initiating a VACUUM when the database reaches a certain size, instead initiative a VACUUM when:
(number of free pages)/(number of total pages) >= some fraction
that's what VACUUM really does -- it rewrites the database so there are no free pages, and all the existing pages are contiguous. There would still be a check interval. So you can imagine launching a node like so:
rqlited -auto-vacuum-int=1d -auto-vacuum-free=50
which would tell rqlite to consider doing a VACUUM every day, and only proceeding if the fraction of free pages has hit 50%.
Sound good @jmordica ? This would avoid any useless VACUUMs just because the database reached a certain size, but free page count was actually quite low.
from rqlite.
I think we can make this even easier to operate, and ditch the timer. We simply state that rqlite will perform an automatic vacuum anytime the free/total page ratio gets above the specified fraction. Since VACUUM (as best that I can tell) ends up reducing the free count to zero, rqlite will naturally wait until it needs to VACUUM again. It's basically like JVM, Go, etc and garbage collection. It's more-or-less self-rate-limiting.
from rqlite.
Related Issues (20)
- Add "vtypes" field to API response to indicate actual value types
- Read-only node showing failed to open store: set log info: failed to get last command index HOT 4
- Can't create a empty database in rqlite shell HOT 3
- failed to install snapshot HOT 26
- Leader election times seem too long with max current term HOT 16
- Recovery process can result in old snapshot getting sent to node HOT 43
- Rust sqlx-rqlite HOT 1
- CLI support Home and End key
- Build and upload binaries automatically HOT 4
- Which version of Sqlite dialect is supported? HOT 4
- PRAGMA foreign_keys are turning them off even we turn them on. HOT 4
- connect rqlite over unix sockets HOT 2
- how to debug random "database disk image is malformed" error? HOT 10
- rqlited + DNS client 100% CPU usage after network disconnecting (windows) HOT 21
- CTRL-C should stop the process HOT 1
- [FeatureRequest] Make number of retries configurable for /nodes and potentially other relevant http calls HOT 7
- Build from source fails in Windows VM HOT 7
- Synchronisation bug related to http.Server.AllowedOrigin HOT 1
- Dynamic backup file naming HOT 9
- Multiple issues with snapshot process HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rqlite.