From decef74503bd65612b5d99c4460ce49595187710 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Wed, 16 Nov 2022 08:28:19 -0500 Subject: [PATCH] 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. --- pageserver/src/tenant.rs | 5 ++++- test_runner/regress/test_tenants.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index 58257a6ca8..ae048bd960 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -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"); diff --git a/test_runner/regress/test_tenants.py b/test_runner/regress/test_tenants.py index 1a8bcdfd92..37c9fe951b 100644 --- a/test_runner/regress/test_tenants.py +++ b/test_runner/regress/test_tenants.py @@ -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()