M10.9d: batch durable action lookups (one per poll, one per commit)
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m41s
Foundation / checks (network) (push) Successful in 13m33s
Foundation / checks (tsan) (push) Successful in 7m54s
Foundation / checks (checks) (push) Successful in 32m56s
Foundation / checks (postgres) (push) Successful in 46m10s
Foundation / postgres-tools (push) Successful in 18s
Foundation / image (push) Successful in 2m33s
Foundation / server-image (push) Successful in 4m24s
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m41s
Foundation / checks (network) (push) Successful in 13m33s
Foundation / checks (tsan) (push) Successful in 7m54s
Foundation / checks (checks) (push) Successful in 32m56s
Foundation / checks (postgres) (push) Successful in 46m10s
Foundation / postgres-tools (push) Successful in 18s
Foundation / image (push) Successful in 2m33s
Foundation / server-image (push) Successful in 4m24s
The fourth dev drill showed a synchronous PostgreSQL round trip per action on the simulation thread: at admission (uniqueness) and again at commit (first-record rule). About 12 lookups landed on each commit tick (commit ticks 58-70 ms, session p99 30-39 ms). - ActionLedger::find_all; persistence::find_region_actions applies the schema v11 find_region_action to many pairs in one statement (no migration). - IntentAdmission::admit/verify: actions only the ledger can refuse wait for one verify per poll; receipts still go out in the same poll. committed() asks once per commit. - Tests: deferred_actions (network_control), find_region_actions and find_all (Postgres). - ADR-0097 fourth run, ADR-0092 amendment, VALIDATION; refresh the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,4 +25,38 @@ PostgresActionLedger::find(const network::AccountId& account, std::uint64_t acti
|
||||
network::ActionOutcome{action_id, network::ActionResult::committed_no_effect,
|
||||
record.value().tick, record.value().commit_sequence}};
|
||||
}
|
||||
|
||||
std::expected<std::vector<std::optional<network::ActionOutcome>>, network::ActionLedgerError>
|
||||
PostgresActionLedger::find_all(std::span<const network::ActionKey> keys) {
|
||||
const auto lease = lease_();
|
||||
if (!lease)
|
||||
return std::unexpected(network::ActionLedgerError::unavailable);
|
||||
auto* db = db_->get();
|
||||
if (!db)
|
||||
return std::unexpected(network::ActionLedgerError::unavailable);
|
||||
std::vector<persistence::ActionRef> refs;
|
||||
refs.reserve(keys.size());
|
||||
for (const auto& k : keys)
|
||||
refs.push_back({k.account.bytes, k.action_id});
|
||||
const auto found = persistence::find_region_actions(*db, key_, *lease, refs, timeout_);
|
||||
if (!found.has_value()) {
|
||||
const auto kind = found.error().kind;
|
||||
if (kind == persistence::LeaseStoreError::store ||
|
||||
kind == persistence::LeaseStoreError::unknown)
|
||||
db_->broken(); // Reconnect next time.
|
||||
return std::unexpected(network::ActionLedgerError::unavailable);
|
||||
}
|
||||
std::vector<std::optional<network::ActionOutcome>> out;
|
||||
out.reserve(keys.size());
|
||||
for (std::size_t i = 0; i < keys.size(); ++i) {
|
||||
const auto& record = (*found)[i];
|
||||
if (record.has_value())
|
||||
out.emplace_back(network::ActionOutcome{keys[i].action_id,
|
||||
network::ActionResult::committed_no_effect,
|
||||
record->tick, record->commit_sequence});
|
||||
else
|
||||
out.emplace_back();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace evo::server
|
||||
|
||||
@@ -504,6 +504,16 @@ struct RegionSessions::Impl {
|
||||
markers.set_ghosts(ghosts);
|
||||
}
|
||||
|
||||
void answer(Connection& c, const network::ActionReceipt& receipt) {
|
||||
send(c, receipt);
|
||||
// A duplicate of a final action: answer with the outcome as well.
|
||||
if (receipt.status == network::AdmitStatus::duplicate)
|
||||
if (const auto o = intents.query(c.session, {receipt.action_id}, admission());
|
||||
o.result == network::ActionResult::committed_no_effect ||
|
||||
o.result == network::ActionResult::not_committed)
|
||||
send(c, o);
|
||||
}
|
||||
|
||||
void deliver(const std::vector<network::AccountOutcome>& outcomes) {
|
||||
for (const auto& o : outcomes)
|
||||
if (const auto session = intents.session_of(o.account))
|
||||
@@ -532,14 +542,9 @@ struct RegionSessions::Impl {
|
||||
if (const auto* m = std::get_if<network::SessionRefresh>(&*decoded))
|
||||
return refresh(c, *m, now_seconds, now);
|
||||
if (const auto* m = std::get_if<network::SessionAction>(&*decoded)) {
|
||||
const auto receipt = intents.action(c.session, *m, admission());
|
||||
send(c, receipt);
|
||||
// A duplicate of a final action: answer with the outcome as well.
|
||||
if (receipt.status == network::AdmitStatus::duplicate)
|
||||
if (const auto o = intents.query(c.session, {m->action_id}, admission());
|
||||
o.result == network::ActionResult::committed_no_effect ||
|
||||
o.result == network::ActionResult::not_committed)
|
||||
send(c, o);
|
||||
// A durable uniqueness check waits for this poll's single `verify` (M10.9d).
|
||||
if (const auto receipt = intents.admit(c.session, *m, admission()))
|
||||
answer(c, *receipt);
|
||||
return;
|
||||
}
|
||||
if (const auto* m = std::get_if<network::ActionQuery>(&*decoded))
|
||||
@@ -676,6 +681,10 @@ void RegionSessions::poll(const HostFacts& facts, std::uint64_t now_seconds,
|
||||
m.datagram(*c, e.bytes, now);
|
||||
}
|
||||
}
|
||||
// One ledger request for every action admitted by this poll's messages.
|
||||
for (const auto& [session, receipt] : m.intents.verify(m.admission()))
|
||||
if (auto* c = m.by_session(session); c && c->state == Impl::State::established)
|
||||
m.answer(*c, receipt);
|
||||
for (const auto& [session, watermark] : m.intents.simulated(m.admission()))
|
||||
if (auto* c = m.by_session(session); c && c->state == Impl::State::established)
|
||||
m.send_datagram(*c, watermark);
|
||||
|
||||
Reference in New Issue
Block a user