Add TenantTaskManager

This commit is contained in:
Bojan Serafimov
2022-06-15 09:24:46 -04:00
parent ee36ca54d5
commit 02a9883f0f
3 changed files with 4 additions and 10 deletions

View File

@@ -230,8 +230,6 @@ pub fn shutdown_all_tenants() {
drop(m);
thread_mgr::shutdown_threads(Some(ThreadKind::WalReceiverManager), None, None);
thread_mgr::shutdown_threads(Some(ThreadKind::GarbageCollector), None, None);
thread_mgr::shutdown_threads(Some(ThreadKind::Compactor), None, None);
// Ok, no background threads running anymore. Flush any remaining data in
// memory to disk.
@@ -344,8 +342,6 @@ pub fn set_tenant_state(tenant_id: ZTenantId, new_state: TenantState) -> anyhow:
Some(tenant_id),
None,
);
thread_mgr::shutdown_threads(Some(ThreadKind::GarbageCollector), Some(tenant_id), None);
thread_mgr::shutdown_threads(Some(ThreadKind::Compactor), Some(tenant_id), None);
}
}

View File

@@ -95,7 +95,7 @@ pub fn init_tenant_task_pool() -> Result<()> {
START_COMPACTION_LOOP.set(compaction_send).unwrap();
thread_mgr::spawn(
ThreadKind::WalReceiverManager, // TODO
ThreadKind::TenantTaskManager,
None,
None,
"WAL receiver manager main thread",
@@ -105,6 +105,7 @@ pub fn init_tenant_task_pool() -> Result<()> {
loop {
tokio::select! {
_ = thread_mgr::shutdown_watcher() => break,
// TODO don't spawn if already running
tenantid = gc_recv.recv() => {
tokio::spawn(gc_loop(tenantid.unwrap()));
},

View File

@@ -94,11 +94,8 @@ pub enum ThreadKind {
// Main walreceiver manager thread that ensures that every timeline spawns a connection to safekeeper, to fetch WAL.
WalReceiverManager,
// Thread that handles compaction of all timelines for a tenant.
Compactor,
// Thread that handles GC of a tenant
GarbageCollector,
// Thread that schedules new compaction and gc jobs
TenantTaskManager,
// Thread that flushes frozen in-memory layers to disk
LayerFlushThread,