fix(filler): defer update_atomicmarket_stats_market while the reader is catching up#68
Conversation
…hes up
update_atomicmarket_stats_market() recomputes the whole due backlog in one
unbounded statement. Every other heavy maintenance job (update_atomicmarket_
template_prices, the sales-filter drain) is gated on Filler.shouldDeferDrain(),
but this one was not — so against a catchup-sized atomicmarket_stats_markets_
updates backlog it busts the connection statement_timeout (57014) on every
2-minute tick and contends with block-writes ("No blocks processed").
Gate it like its siblings: skip while the reader is far behind head; stats
refresh on the next tick once the reader is live.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a drain-deferral gate to avoid expensive/unbounded stats recomputation queries while the reader is catching up, reducing statement timeouts and write contention during backlog recovery.
Changes:
- Skip
update_atomicmarket_stats_market()execution whenshouldDeferDrain()indicates the reader is catching up. - Document why the gate exists (statement timeout / contention) and how it aligns with other existing gates.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Reader-priority gate: skip the stats recompute while the reader is catching up. | ||
| // update_atomicmarket_stats_market() processes every due row in | ||
| // atomicmarket_stats_markets_updates in a single unbounded statement, so against a | ||
| // catchup-sized backlog it busts this connection's statement_timeout on every 2min | ||
| // tick (57014) and contends with block-writes. It refreshes on the next tick once the | ||
| // reader is live. Mirrors the gate on update_atomicmarket_template_prices below and | ||
| // the sales-filter drain above. | ||
| if (this.filler.shouldDeferDrain()) { | ||
| return; | ||
| } |
robrigo
left a comment
There was a problem hiding this comment.
Review (FACINGS) — LGTM.
Verified Filler.shouldDeferDrain() exists and that the sibling heavy jobs (sales-filter drain + update_atomicmarket_template_prices) use the same gate — update_atomicmarket_stats_market was the lone ungated one. Confirmed the same gap exists on feat/atomicassets-v2 (its stats_market job is ungated too), so this is needed there as well; the patch applies cleanly onto v2.
Copilot's note (silent skip is hard to observe during catch-up) is fair but consistent with the existing sibling gates, which are also silent — fine as an optional follow-up (a rate-limited debug log), not a blocker.
AtomicAssets v2 (dual ownership/renting, mutable templates, schema media types, collection author swaps) was originally authored by Fabian Emilius in the WAX-OIG eosio-contract-api fork; this repo carries it forward as a reconstruction onto 1.7.2. Record the original authorship and co-attribute it. Also credits @igorls for the v2 catch-up/upgrade-safety fixes (#68/#69/#70). Co-authored-by: Fabian Emilius <20770096+fabian-emilius@users.noreply.github.com> Co-authored-by: Igor Lins e Silva <4753812+igorls@users.noreply.github.com>
|
Rechecked against current |
Problem
update_atomicmarket_stats_market()recomputes the whole due backlog in a single unbounded statement. Every other heavy maintenance job —update_atomicmarket_template_pricesand the sales-filter drain — is gated onFiller.shouldDeferDrain(), but this one is not.On a catchup-sized
atomicmarket_stats_markets_updatesbacklog the recompute exceeds the connectionstatement_timeoutand is cancelled (57014) on every 2-minute tick, so market stats never refresh during catchup and the doomed query contends with block-writes (intermittentNo blocks processed … Stopping in N seconds).Observed on a production WAX-mainnet cluster: the job timed out every tick against a ~3.3M-row
atomicmarket_stats_markets_updatesbacklog while the reader was ~1.3M blocks behind head.Fix
Gate the job on
this.filler.shouldDeferDrain(), exactly like its siblings: skip while the reader is catching up; stats refresh on the next tick once the reader is live.Validation
pnpm check-typesclean.57014s stop and the reader no longer competes with the stats recompute during catchup.