Add M10.4b durable action records (schema v11)
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 9m30s
Foundation / checks (client) (push) Successful in 12m19s
Foundation / checks (tsan) (push) Successful in 7m43s
Foundation / checks (checks) (push) Successful in 31m29s
Foundation / checks (postgres) (push) Successful in 36m39s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m15s
Foundation / server-image (push) Successful in 20m37s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 9m30s
Foundation / checks (client) (push) Successful in 12m19s
Foundation / checks (tsan) (push) Successful in 7m43s
Foundation / checks (checks) (push) Successful in 31m29s
Foundation / checks (postgres) (push) Successful in 36m39s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m15s
Foundation / server-image (push) Successful in 20m37s
Each batch's actions are recorded in the same statement as its checkpoint: one region_actions row per (world, account, action id) and the block in an append-only table, compared on exact retries and resolution. The region host attaches actions to the ticks they ride and reports acknowledgements and drops, keeping unknown-outcome batches unresolved. Outcomes come from the durable record via ActionLedger, so crashes before or after a commit, unknown publications and cross-region moves all resolve to one answer; a repeated id keeps its first record instead of stalling a region. ADR-0092. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -100,6 +100,27 @@ std::expected<void, AdmissionError> RegionHost<State>::submit(const TickInput& i
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename State>
|
||||
std::expected<void, AdmissionError>
|
||||
RegionHost<State>::submit_action(const persistence::ActionRecord& record) {
|
||||
if (record.account == persistence::Uuid{} || record.action_id == 0 || record.kind != 1 ||
|
||||
record.tick == 0)
|
||||
return std::unexpected{AdmissionError::invalid};
|
||||
if (draining_)
|
||||
return std::unexpected{AdmissionError::draining};
|
||||
if (!status_.ready)
|
||||
return std::unexpected{AdmissionError::not_ready};
|
||||
const auto same = [&](const persistence::ActionRecord& a) {
|
||||
return a.account == record.account && a.action_id == record.action_id;
|
||||
};
|
||||
if (std::ranges::any_of(action_queue_, same) || std::ranges::any_of(batch_actions_, same))
|
||||
return std::unexpected{AdmissionError::duplicate};
|
||||
if (action_queue_.size() + batch_actions_.size() >= config_.max_queued_actions)
|
||||
return std::unexpected{AdmissionError::full};
|
||||
action_queue_.push_back(record);
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename State> bool RegionHost<State>::database() {
|
||||
if (db_)
|
||||
return true;
|
||||
@@ -118,6 +139,13 @@ void RegionHost<State>::lose_authority(Unacknowledged reason, HostPhase next) {
|
||||
dropped_.push_back({a.input, reason});
|
||||
for (auto& q : queue_)
|
||||
dropped_.push_back({q, reason});
|
||||
// Actions of a batch whose publication outcome is unknown may be durable: not final.
|
||||
for (const auto& a : batch_actions_)
|
||||
dropped_actions_.push_back({a, !prepared_.has_value(), reason});
|
||||
for (const auto& a : action_queue_)
|
||||
dropped_actions_.push_back({a, true, reason});
|
||||
batch_actions_.clear();
|
||||
action_queue_.clear();
|
||||
applied_.clear();
|
||||
queue_.clear();
|
||||
batch_.reset(); // References state_: reset first.
|
||||
@@ -248,6 +276,9 @@ void RegionHost<State>::confirmed(const persistence::PublishedBatch& published,
|
||||
applied_.clear();
|
||||
for (const auto& d : published.decisions)
|
||||
outcomes_.push_back({d, head.sequence});
|
||||
for (const auto& a : batch_actions_)
|
||||
action_acks_.push_back({a, head.sequence});
|
||||
batch_actions_.clear();
|
||||
prepared_.reset();
|
||||
batch_started_ = now;
|
||||
retry_at_ = {};
|
||||
@@ -272,9 +303,9 @@ template <typename State> void RegionHost<State>::commit(SchedulerTime now) {
|
||||
persistence::PublishHooks hooks;
|
||||
if (crash)
|
||||
hooks.before_transaction = [&crash] { crash(CrashPoint::before_transaction); };
|
||||
auto published =
|
||||
Ops<State>::publish(*db_, *objects_, *grant, *committed_, *batch_, commit_id, config_.build,
|
||||
config_.restore_budget, config_.lease.commit_timeout, hooks);
|
||||
auto published = Ops<State>::publish(*db_, *objects_, *grant, *committed_, *batch_, commit_id,
|
||||
config_.build, config_.restore_budget,
|
||||
config_.lease.commit_timeout, hooks, batch_actions_);
|
||||
if (published) {
|
||||
confirmed(*published, now);
|
||||
return;
|
||||
@@ -387,6 +418,14 @@ template <typename State> void RegionHost<State>::simulate(SchedulerTime now) {
|
||||
continue;
|
||||
}
|
||||
applied_.push_back({input, report->tick});
|
||||
// Actions due at or before this tick ride it (late ones ride the first tick run).
|
||||
std::erase_if(action_queue_, [&](persistence::ActionRecord action) {
|
||||
if (action.tick > report->tick)
|
||||
return false;
|
||||
action.tick = report->tick;
|
||||
batch_actions_.push_back(action);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,6 +521,9 @@ template <typename State> void RegionHost<State>::drain() {
|
||||
for (auto& q : queue_)
|
||||
dropped_.push_back({q, Unacknowledged::drained});
|
||||
queue_.clear();
|
||||
for (const auto& a : action_queue_)
|
||||
dropped_actions_.push_back({a, true, Unacknowledged::drained});
|
||||
action_queue_.clear();
|
||||
if (status_.phase == HostPhase::running)
|
||||
status_.phase = HostPhase::draining;
|
||||
else if (status_.phase == HostPhase::acquiring)
|
||||
@@ -498,6 +540,12 @@ template <typename State> std::vector<FinalOutcome> RegionHost<State>::take_outc
|
||||
template <typename State> std::vector<Dropped> RegionHost<State>::take_dropped() {
|
||||
return std::exchange(dropped_, {});
|
||||
}
|
||||
template <typename State> std::vector<ActionAck> RegionHost<State>::take_action_acks() {
|
||||
return std::exchange(action_acks_, {});
|
||||
}
|
||||
template <typename State> std::vector<DroppedAction> RegionHost<State>::take_dropped_actions() {
|
||||
return std::exchange(dropped_actions_, {});
|
||||
}
|
||||
|
||||
template class RegionHost<processes::EnvironmentalCommunity>;
|
||||
template class RegionHost<processes::LineageRegion>;
|
||||
|
||||
Reference in New Issue
Block a user