don't start background jobs if tenant has not timelines

Before this change, test_pageserver_with_empty_tenants was failing at:

  assert loaded_tenant["state"] == {
        "Active": {"background_jobs_running": False}
    }, "Tenant {tenant_with_empty_timelines_dir} with empty timelines dir should be active and ready for timeline creation"

because background_jobs_running was True instead of False.

Personally I think we should simply always start the background loops
and not bother, but let's punt this until after we've merged this PR.
This commit is contained in:
Christian Schwarz
2022-11-16 08:28:19 -05:00
committed by Dmitry Rodionov
parent 8aed805933
commit decef74503
2 changed files with 7 additions and 3 deletions

View File

@@ -809,6 +809,9 @@ impl Tenant {
// FIXME original collect_timeline_files contained one more check:
// 1. "Timeline has no ancestor and no layer files"
// XXX get rid of enable_background_jobs
let enable_background_jobs = sorted_timelines.len() > 0;
for (timeline_id, metadata) in sorted_timelines {
// FIXME should we fail load of whole tenant if one timeline failed?
// consider branch hierarchy. Maybe set one to broken and others to Paused or something
@@ -818,7 +821,7 @@ impl Tenant {
// We're ready for business.
// Change to active state under the hood spawns background loops
// The loops will shut themselves down when they notice that the tenant is inactive.
self.activate(true);
self.activate(enable_background_jobs);
info!("Done");

View File

@@ -217,8 +217,9 @@ def test_pageserver_with_empty_tenants(
env.pageserver.allowed_errors.append(
".*marking .* as locally complete, while it doesnt exist in remote index.*"
)
env.pageserver.allowed_errors.append(".*Tenant .* has no timelines directory.*")
env.pageserver.allowed_errors.append(".*No timelines to attach received.*")
env.pageserver.allowed_errors.append(
".*could not load tenant.*Failed to list timelines directory.*"
)
client = env.pageserver.http_client()