Skip to content

perf(cron): reuse the selected diagnostic partition and startup refresh - #180875

Merged
steipete merged 1 commit into
mainfrom
dbasync/autoproj
Oct 22, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/autoproj

Conversation

@steipete

@steipete steipete commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway health and the Automations projection now read the cron partition already selected by their live service. Previously each diagnostic request reselected cron.store from persisted machine state and ignored a different cfg.cron.store, so diagnostics could show a different partition than the cron service. Standalone readers retain their existing partition-selection fallback.

Cron startup also refreshed the legacy projection twice. The lifecycle now owns the initial startup and same-service restart refresh; live provisioning continues to refresh after startup. Restart reopens the projection before reading it, and read failures remain visible warnings without disabling cron.

Cost and boundaries

Two alternating frozen v3.1.4 base/candidate pairs confirm 56 → 36 SQL and 14 → 12 requests for automationProactive.jobs: −20 statements / −2 requests / 0 MAIN per workload. The runner stopped before pair three when host load reached 70.5, above the measurement limit. All four arms completed the full workload and restart. All 36 frozen harness hashes matched.

The table reports SQL / requests / MAIN medians [min–max] across the two arms per revision.

Operation or phase Base Candidate
automationProactive.jobs 56 [56–56] / 14 [14–14] / 0 [0–0] 36 [36–36] / 12 [12–12] / 0 [0–0]
Whole workload 2967 [2963–2971] / 801.5 [798–805] / 96 [96–96] 2919.5 [2916–2923] / 796.5 [795–798] / 97 [96–98]
01.boot 283.5 [282–285] / 81.5 [79–84] / 49 [49–49] 284.5 [284–285] / 83 [81–85] / 49.5 [49–50]
06.cron 238.5 [235–242] / 64 [64–64] / 0 [0–0] 240.5 [240–241] / 64 [64–64] / 0 [0–0]
07.idle-settle 100.5 [99–102] / 15.5 [14–17] / 0 [0–0] 99.5 [97–102] / 15.5 [14–17] / 0 [0–0]
07.idle-connected 120 [120–120] / 42 [42–42] / 0 [0–0] 114.5 [114–115] / 41.5 [41–42] / 0 [0–0]
09.restart-boot 295.5 [292–299] / 102.5 [102–103] / 37 [37–37] 301 [292–310] / 104 [102–106] / 37.5 [37–38]

Warm causal medians remain 45 [45–48] / 11 [11–12] / 0 [0–0]. Exact-entry facts, actor hydration, projection snapshots, shared row facts, worker environment snapshots, and watermark reads do not increase. Raw totals include background timing variation; two extra candidate busy_timeout PRAGMAs occurred during loaded boot/restart in the second pair. They are outside the changed operation. cron.loadMutable is 7 SQL / 7 requests in both bases and the first candidate, and 9 / 9 in the second candidate: both extra calls come from registry-maintenance sweeps (one during first turn, one during restart); the four startup/read call sites remain unchanged. No aggregate or latency improvement is claimed.

No schema, SQL syntax, transaction, retention, or authority changes. Health continues reading current receipts. A same-audience diagnostic request may join an in-flight refresh that captured the previous service during reload; the next refresh uses the current owner. This accepted diagnostic staleness does not affect cron execution or sensitive-audience separation.

Evidence

  • Real-worker count regression is red on base and proves the removed partition-selection read, committed updates, standalone fallback, and reselection.
  • Lifecycle count regression is red on base and proves one projection request per initial start/restart, retained receipt membership changes, actual cron execution reporting, and observable read failure.
  • Kernel regression proves the retained health request context follows replacement of the cron state. All 136 focused tests pass.
  • Two independent Codex review rounds found no actionable P0–P2 findings. Exact-head PostgreSQL and coordinator reviews approved.
  • CI 39830733304 passed, including all three PostgreSQL shards, types, lint, architecture, source contracts, and worker/dialect ratchets.
  • Exact integrated-base/head Knip scans both report 41 production / 59 full-tree / 0 script findings: zero additions or removals. The local dependency-layout guard stops typechecking before compilation; CI supplied the type proof.
  • All 34 open main-targeted PR merge comparisons preserve their existing conflicts except the approved mechanical overlap noted below.
  • Published-driver update acceptance passed on the exact head, including the published-driver-update lane.

Nine files: +342/−5 overall; production +17/−5. Release-note context: corrects cron diagnostic partition selection and reduces redundant database work during diagnostics and startup while preserving standalone selection, provisioning, and restart behavior.

Note for #89526: rebase conflict in health-state.ts is mechanical — keep cronStorePath in the reindented snapshot object.

Pass the Gateway-owned cron partition through health diagnostics and retain the lifecycle-owned projection refresh at startup and restart. Live provisioning refreshes remain active; standalone readers continue to resolve their own partition. Count regressions cover removed selection SQL and duplicate startup requests, with committed-update, restart, warning, and runtime-owner replacement proof.
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T18:25:33.353143Z 2aecb62 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Oct 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2aecb6206d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

audience,
probe: strength === "probe",
runtimeSnapshot,
cronStorePath: opts?.getCronStorePath?.(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Separate health refresh joins by cron partition

When a refresh has already captured the old cron path and a hot reload swaps runtimeState.cronState, a subsequent request with the same audience and strength returns the existing promise at lines 189–191 without consulting getCronStorePath, so that request still reports heartbeat diagnostics from the retired partition. Since this change makes the cron path an answer-changing input, include it in the in-flight identity or invalidate/generate the slot when the cron owner changes.

AGENTS.md reference: AGENTS.md:L69-L69

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

The in-flight reload overlap is an accepted diagnostic edge for this change: a same-audience request can join a refresh that already captured the previous cron service, and the next refresh reads the current owner. This does not route cron execution or change the existing sensitive-audience separation. The PR now states that case explicitly. Adding another generation/invalidation mechanism for a recoverable diagnostic snapshot would exceed the intended owner-reuse simplification; no change is planned for this finding.

@steipete
steipete merged commit 978c086 into main Oct 22, 2026
212 of 216 checks passed
@steipete
steipete deleted the dbasync/autoproj branch October 22, 2026 19:02
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…sh (openclaw#180875)

Use the live cron service partition for health and Automations diagnostics, including config-selected stores. Keep one lifecycle-owned startup/restart projection refresh while preserving live provisioning and standalone selection.

Frozen workload: automationProactive.jobs 56 to 36 SQL, 14 to 12 requests; warm causal 45/11/0 unchanged. Exact-head CI, PostgreSQL review, and published-driver update acceptance passed.
amittell added a commit to amittell/openclaw that referenced this pull request Oct 23, 2026
Main 784d9ce conflicted in two files.

server-methods/health.ts: keep this branch's respondFresh path and runtime-config client filter, and add main's live coreReady (openclaw#180924) to both the cached and the fresh response objects inside the filter.
server/health-state.ts: keep this branch's config-key fenced collection loop, and pass main's cronStorePath (openclaw#180875) to its collectGatewayHealthSnapshot call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant