From 62ceea46f33fe6a6704b40aaa2c980c8b29eff5e Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 19 Mar 2024 16:56:26 +0100 Subject: serve target: Fix sharding inconsistencies When running in single node, serve endpoint should not even consider sharding. Additionally, garbage collection uplinking should also take the shard into account. For this purpose, a TargetCache instance now remembers if it was explicitly sharded and passed that information to the GarbageCollector for uplinking. --- src/buildtool/serve_api/serve_service/target.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/buildtool/serve_api/serve_service/target.cpp') diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index 67102c49..c5b9aa60 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -180,13 +180,14 @@ auto TargetService::ServeTarget( } // get a target cache instance with the correct computed shard - auto const& tc = Storage::Instance().TargetCache().WithShard( - untagged_execution_backend.hash()); + auto shard = address ? std::make_optional(untagged_execution_backend.hash()) + : std::nullopt; + auto const& tc = Storage::Instance().TargetCache().WithShard(shard); auto const& tc_key = TargetCacheKey{{target_cache_key_digest, ObjectType::File}}; // check if target-level cache entry has already been computed - if (auto target_entry = tc->Read(tc_key); target_entry) { + if (auto target_entry = tc.Read(tc_key); target_entry) { // make sure all artifacts referenced in the target cache value are in // the remote cas @@ -413,7 +414,7 @@ auto TargetService::ServeTarget( auto result = AnalyseTarget(configured_target, &result_map, &repository_config, - *tc, + tc, &stats, RemoteServeConfig::Jobs(), std::nullopt /*request_action_input*/, @@ -528,7 +529,7 @@ auto TargetService::ServeTarget( traverser.GetLocalApi(), traverser.GetRemoteApi(), RemoteServeConfig::TCStrategy(), - *tc, + tc, &logger, true /*strict_logging*/); @@ -565,7 +566,7 @@ auto TargetService::ServeTarget( // now that the target cache key is in, make sure remote CAS has all // required entries - if (auto target_entry = tc->Read(tc_key); target_entry) { + if (auto target_entry = tc.Read(tc_key); target_entry) { // make sure all artifacts referenced in the target cache value are in // the remote cas std::vector tc_artifacts; -- cgit v1.2.3