mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Server: Vacuum database on startup
Runs after the migrations. In some cases, it can reclaim a significant amount of space (reported 30%).
This commit is contained in:
parent
5e5665ea19
commit
021a8be62e
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Currently playing music track and artist now shows in the debug menu.
|
- Currently playing music track and artist now shows in the debug menu.
|
||||||
- Added a setting to influence the gap between music track plays.
|
- Added a setting to influence the gap between music track plays.
|
||||||
- Added a Craft All button.
|
- Added a Craft All button.
|
||||||
|
- Server: Vacuum database on startup
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Use fluent for translations
|
- Use fluent for translations
|
||||||
|
@ -230,6 +230,10 @@ impl Server {
|
|||||||
debug!("Running DB migrations...");
|
debug!("Running DB migrations...");
|
||||||
persistence::run_migrations(&database_settings);
|
persistence::run_migrations(&database_settings);
|
||||||
|
|
||||||
|
// Vacuum database
|
||||||
|
debug!("Vacuuming database...");
|
||||||
|
persistence::vacuum_database(&database_settings);
|
||||||
|
|
||||||
let database_settings = Arc::new(RwLock::new(database_settings));
|
let database_settings = Arc::new(RwLock::new(database_settings));
|
||||||
|
|
||||||
let registry = Arc::new(Registry::new());
|
let registry = Arc::new(Registry::new());
|
||||||
|
@ -172,6 +172,18 @@ pub fn run_migrations(settings: &DatabaseSettings) {
|
|||||||
info!("Applied {} database migrations", applied_migrations);
|
info!("Applied {} database migrations", applied_migrations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runs after the migrations. In some cases, it can reclaim a significant
|
||||||
|
/// amount of space (reported 30%)
|
||||||
|
pub fn vacuum_database(settings: &DatabaseSettings) {
|
||||||
|
let conn = establish_connection(settings, ConnectionMode::ReadWrite);
|
||||||
|
|
||||||
|
// The params type is phony; it's required, but not meaningful.
|
||||||
|
conn.execute::<&[u32]>("VACUUM main", &[])
|
||||||
|
.expect("Database vacuuming failed, server startup aborted");
|
||||||
|
|
||||||
|
info!("Database vacuumed");
|
||||||
|
}
|
||||||
|
|
||||||
// These callbacks use info logging because they are never enabled by default,
|
// These callbacks use info logging because they are never enabled by default,
|
||||||
// only when explicitly turned on via CLI arguments or interactive CLI commands.
|
// only when explicitly turned on via CLI arguments or interactive CLI commands.
|
||||||
// Setting them to anything other than info would remove the ability to get SQL
|
// Setting them to anything other than info would remove the ability to get SQL
|
||||||
|
Loading…
Reference in New Issue
Block a user