Start background loops on create_tenant correctly.

This was caught by the test_gc_cutoff test.
This commit is contained in:
Heikki Linnakangas
2022-11-24 15:26:33 +02:00
committed by Christian Schwarz
parent c2f5d011c7
commit 0260ee23b9

View File

@@ -707,16 +707,17 @@ impl Tenant {
) -> anyhow::Result<Arc<Tenant>> {
let wal_redo_manager = Arc::new(PostgresRedoManager::new(conf, tenant_id));
create_tenant_files(conf, tenant_conf, tenant_id)?;
// create tenant in Active state so it is possible to issue create_timeline
// request. Which on timeline activation will trigger tenant activation
// create tenant in Loading state, and activate it immediately so that it is
// possible to issue create_timeline request on it.
let tenant = Arc::new(Tenant::new(
TenantState::Active,
TenantState::Loading,
conf,
tenant_conf,
wal_redo_manager,
tenant_id,
remote_storage,
));
tenant.activate()?;
Ok(tenant)
}
@@ -1287,6 +1288,8 @@ impl Tenant {
TenantState::Loading | TenantState::Attaching => {
*current_state = TenantState::Active;
info!("Activating tenant {}", self.tenant_id);
let timelines_accessor = self.timelines.lock().unwrap();
let not_broken_timelines = timelines_accessor
.values()