Start GC in page cache initialization rather than during branch creation

This commit is contained in:
Konstantin Knizhnik
2021-08-02 19:59:12 +03:00
parent 6b2e7d9499
commit 534fd33e3d
2 changed files with 21 additions and 17 deletions

View File

@@ -47,6 +47,7 @@ pub fn init_pageserver(
workdir: &Path,
create_tenant: Option<&str>,
) -> Result<()> {
env::set_current_dir(workdir)?;
// Initialize logger
@@ -104,17 +105,11 @@ pub fn create_repo(
// rapid init+start case now, but the general race condition remains if you restart the
// server quickly.
let repo: Arc<dyn Repository + Sync + Send> = match conf.repository_format {
RepositoryFormat::Layered => {
let repo = Arc::new(crate::layered_repository::LayeredRepository::new(
conf,
wal_redo_manager,
tenantid,
));
if conf.gc_horizon != 0 {
crate::layered_repository::LayeredRepository::launch_gc_thread(conf, repo.clone());
}
repo
}
RepositoryFormat::Layered => Arc::new(
crate::layered_repository::LayeredRepository::new(conf,
wal_redo_manager,
tenantid
)),
RepositoryFormat::RocksDb => {
let obj_store = crate::rocksdb_storage::RocksObjectStore::create(conf, &tenantid)?;
@@ -122,7 +117,7 @@ pub fn create_repo(
conf,
Arc::new(obj_store),
wal_redo_manager,
tenantid,
tenantid
))
}
};

View File

@@ -33,10 +33,19 @@ pub fn init(conf: &'static PageServerConf) {
// Set up an object repository, for actual data storage.
let repo: Arc<dyn Repository + Sync + Send> = match conf.repository_format {
RepositoryFormat::Layered => Arc::new(LayeredRepository::new(conf,
Arc::new(walredo_mgr),
tenantid
)),
RepositoryFormat::Layered => {
let repo = Arc::new(LayeredRepository::new(
conf,
Arc::new(walredo_mgr),
tenantid,
));
if conf.gc_horizon != 0 {
crate::layered_repository::LayeredRepository::launch_gc_thread(conf, repo.clone());
} else {
info!("Garbage collection is disabled");
}
repo
}
RepositoryFormat::RocksDb => {
let obj_store = RocksObjectStore::open(conf, &tenantid).unwrap();
@@ -44,7 +53,7 @@ pub fn init(conf: &'static PageServerConf) {
conf,
Arc::new(obj_store),
Arc::new(walredo_mgr),
tenantid
tenantid,
))
}
};