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:
@@ -427,11 +427,76 @@ struct FakeActions final : ActionLedger {
|
||||
return std::optional{outcome};
|
||||
return std::optional<ActionOutcome>{};
|
||||
}
|
||||
std::expected<std::vector<std::optional<ActionOutcome>>, ActionLedgerError>
|
||||
find_all(std::span<const ActionKey> keys) override {
|
||||
++batches;
|
||||
return ActionLedger::find_all(keys); // Counts each pair as a lookup too.
|
||||
}
|
||||
std::vector<std::pair<AccountId, ActionOutcome>> records;
|
||||
bool unavailable{};
|
||||
int lookups{};
|
||||
int lookups{}, batches{};
|
||||
};
|
||||
|
||||
// M10.9d: admission whose durable uniqueness check waits for one `verify` per poll, and a
|
||||
// commit decided with one ledger request.
|
||||
void deferred_actions() {
|
||||
auto a = *IntentAdmission::create(IntentLimits{});
|
||||
FakeActions ledger;
|
||||
a.attach(&ledger);
|
||||
const auto alice = account(1), bob = account(2);
|
||||
CHECK(a.open(1, alice) && a.open(2, bob));
|
||||
AdmissionFacts f{true, 5, 100};
|
||||
const auto admit = [&](std::uint64_t session, std::uint64_t id, std::uint64_t tick) {
|
||||
return a.admit(session, SessionAction{session, 5, id, 1, tick}, f);
|
||||
};
|
||||
ledger.records.emplace_back(alice, ActionOutcome{9, ActionResult::committed_no_effect, 40, 3});
|
||||
CHECK(!admit(1, 9, 101) && !admit(1, 20, 101) && !admit(2, 30, 102));
|
||||
// In-memory refusals answer at once; a repeat of a waiting action is a duplicate.
|
||||
CHECK(admit(1, 20, 101) == ActionReceipt{20, AdmitStatus::duplicate, 100, 101});
|
||||
CHECK(admit(1, 21, 150) == ActionReceipt{21, AdmitStatus::outside_window, 100, 150});
|
||||
CHECK(a.carry(110).empty() && ledger.lookups == 0); // Nothing rides before `verify`.
|
||||
f.server_tick = 101;
|
||||
auto receipts = a.verify(f);
|
||||
CHECK(ledger.batches == 1 && ledger.lookups == 3 && receipts.size() == 3);
|
||||
CHECK(receipts[0] ==
|
||||
std::pair{std::uint64_t{1}, ActionReceipt{9, AdmitStatus::duplicate, 100, 40}});
|
||||
CHECK(receipts[1] ==
|
||||
std::pair{std::uint64_t{1}, ActionReceipt{20, AdmitStatus::admitted, 100, 101}});
|
||||
CHECK(receipts[2] ==
|
||||
std::pair{std::uint64_t{2}, ActionReceipt{30, AdmitStatus::admitted, 100, 102}});
|
||||
CHECK(a.query(1, {9}, f).result == ActionResult::committed_no_effect);
|
||||
CHECK(a.verify(f).empty() && ledger.batches == 1); // Nothing waiting: nothing asked.
|
||||
// One request for a whole commit.
|
||||
const auto riding = a.carry(102);
|
||||
CHECK(riding.size() == 2);
|
||||
const auto outcomes = a.committed(riding, 6);
|
||||
CHECK(ledger.batches == 2 && outcomes.size() == 2 &&
|
||||
outcomes[0].outcome == ActionOutcome{20, ActionResult::committed_no_effect, 101, 6});
|
||||
// Unconfirmed uniqueness, lost readiness and a new epoch refuse what was waiting.
|
||||
f.server_tick = 110; // A new rate window.
|
||||
ledger.unavailable = true;
|
||||
CHECK(!admit(1, 22, 111));
|
||||
receipts = a.verify(f);
|
||||
CHECK(receipts.size() == 1 && receipts[0].second.status == AdmitStatus::not_ready);
|
||||
ledger.unavailable = false;
|
||||
CHECK(a.unresolved(1) == 0);
|
||||
CHECK(!admit(1, 23, 111));
|
||||
f.ready = false;
|
||||
receipts = a.verify(f);
|
||||
CHECK(receipts.size() == 1 && receipts[0].second.status == AdmitStatus::not_ready);
|
||||
f.ready = true;
|
||||
CHECK(!admit(1, 24, 111));
|
||||
f.epoch = 6;
|
||||
receipts = a.verify(f);
|
||||
CHECK(receipts.size() == 1 && receipts[0].second.status == AdmitStatus::stale_epoch);
|
||||
// Without a ledger nothing waits.
|
||||
auto plain = *IntentAdmission::create(IntentLimits{});
|
||||
CHECK(plain.open(1, alice));
|
||||
CHECK(plain.admit(1, SessionAction{1, 5, 7, 1, 101}, AdmissionFacts{true, 5, 100}) ==
|
||||
ActionReceipt{7, AdmitStatus::admitted, 100, 101});
|
||||
CHECK(plain.verify(AdmissionFacts{true, 5, 100}).empty());
|
||||
}
|
||||
|
||||
void durable_actions() {
|
||||
auto a = *IntentAdmission::create(IntentLimits{});
|
||||
FakeActions ledger;
|
||||
@@ -777,5 +842,6 @@ void control_tests() {
|
||||
session_codec();
|
||||
intent_admission();
|
||||
durable_actions();
|
||||
deferred_actions();
|
||||
}
|
||||
} // namespace evo::network_test
|
||||
|
||||
Reference in New Issue
Block a user