Skip to content

Commit a2daca7

Browse files
fix(build): a compiler registration the owner did not answer is sent again
The generation's owner answers one registration at a time, between its audits, and on a loaded macOS runner a scan of a two-configuration workspace waited longer than the two seconds it gave the answer. A registration whose connection the owner accepted is sent again within the startup grace, now one constant for it and for the wait for a supervisor; an owner that accepts no connection has ended, and the compiler ends at once, as the next build waits for it (e2e 1016, 4 of 4). Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent f2aab4c commit a2daca7

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
the object is compiled again (e2e 1022).
3939
- `mcpp test` announces a dependency with its resolved version, as the build
4040
does, not the constraint (`v0.3.1`, not `v^0.3.1`; e2e 196).
41+
- A compiler that registers with its build's generation is answered within the
42+
startup grace: an owner that accepted the registration and did not answer in
43+
two seconds (macOS CI, a scan of a two-configuration workspace: "compiler
44+
registration channel closed or timed out") is asked again, and an owner that
45+
accepts no connection has ended, so the compiler ends at once (e2e 840, 1016).
4146

4247
- A finished detached compiler is recognized when its final status appears
4348
between status and liveness checks. Recovery still validates its output proof.

‎src/build/schedule/compiler_transaction.cppm‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ bool publish(const fs::path& path,std::string_view tag,const Fields& fields);
4848
// is retried with backoff for at most kRecordSettle; a name that is absent is
4949
// absent at once, and a refusal that outlasts the bound is still an error.
5050
inline constexpr auto kRecordSettle=std::chrono::milliseconds(250);
51+
// THE STARTUP GRACE of a compiler's supervision: how long a waiter allows a
52+
// supervisor that has not opened its log, and how long a controller keeps
53+
// registering its unit with the generation's owner. One bound for both, so a
54+
// registration retried within it never outlives the wait for it.
55+
inline constexpr auto kStartupGrace=std::chrono::seconds(10);
5156
enum class Opened { yes, absent, refused };
5257
// Opens `path' for reading, waiting out a publication in progress.
5358
Opened open_settled(std::ifstream& input,const fs::path& path) {
@@ -377,11 +382,25 @@ std::expected<void,std::string> Attempt::register_unit(os::process::owned_unit&
377382
const auto generation=directory.parent_path().parent_path();
378383
auto transport=read(generation/"transport","mcpp-unit-transport-v1");
379384
if(!transport||!*transport||(**transport).size()!=2)return std::unexpected("missing compiler-run registration channel");
380-
auto connection=os::ipc::connection::connect(named((**transport)[0]),(**transport)[1]);
381-
if(!connection||!send(*connection,spelling(directory)))return std::unexpected("cannot register the compiler unit");
382-
auto ack=receive(*connection,std::chrono::seconds(2));
383-
if(!ack||*ack!="ACK")return std::unexpected(ack ? "compiler-run owner refused unit admission" : ack.error());
384-
return {};
385+
// THE OWNER ANSWERS ONE REGISTRATION AT A TIME, between its audits of the
386+
// units it holds, so under load an answer can take longer than one wait for
387+
// it (macOS CI: "compiler registration channel closed or timed out" on a scan
388+
// of a two-configuration workspace). A registration the owner accepted the
389+
// connection of and did not answer is sent again within the startup grace;
390+
// the owner admits a unit under its attempt's name, so a late first answer
391+
// and a second registration admit the same unit once. An owner that accepts
392+
// no connection has ended (a build killed with its controllers still
393+
// starting), and the controller ends at once, as the next build waits for
394+
// it. A refusal is final.
395+
const auto deadline=std::chrono::steady_clock::now()+kStartupGrace;
396+
for(;;) {
397+
auto connection=os::ipc::connection::connect(named((**transport)[0]),(**transport)[1]);
398+
if(!connection||!send(*connection,spelling(directory)))return std::unexpected("cannot register the compiler unit");
399+
auto ack=receive(*connection,std::chrono::seconds(2));
400+
if(ack&&*ack=="ACK")return {};
401+
if(ack)return std::unexpected("compiler-run owner refused unit admission");
402+
if(std::chrono::steady_clock::now()>=deadline)return std::unexpected(ack.error());
403+
}
385404
}
386405

387406
class Witnesses {

‎src/build/schedule/detach_codegen.cppm‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ int compile_release_at_bmi(const CompileRequest& req) {
805805
// half of the same mechanism.
806806
using clock = std::chrono::steady_clock;
807807
const auto started = clock::now();
808-
constexpr auto kNoSupervisorGrace = std::chrono::seconds(10);
808+
constexpr auto kNoSupervisorGrace = transactions::kStartupGrace;
809809
constexpr auto kHardLimit = std::chrono::hours(2);
810810
auto nextControllerCheck=started;
811811

@@ -1018,7 +1018,7 @@ int await_unit(const std::filesystem::path& slot, const std::filesystem::path& o
10181018
// ever opened the log, there is nothing to wait for and this fails at once.
10191019
using clock = std::chrono::steady_clock;
10201020
const auto started = clock::now();
1021-
constexpr auto kNoSupervisorGrace = std::chrono::seconds(10);
1021+
constexpr auto kNoSupervisorGrace = transactions::kStartupGrace;
10221022
constexpr auto kHardLimit = std::chrono::hours(2);
10231023

10241024
std::optional<int> rc;

0 commit comments

Comments
 (0)