Skip to content

feat: TC-4464 node health telemetry and named sqlx pool warnings - #770

Merged
samgbafa merged 3 commits into
mainfrom
skgbafa/tc-4464-node-health-telemetry
Nov 28, 2026
Merged

samgbafa merged 3 commits into
mainfrom
skgbafa/tc-4464-node-health-telemetry

Conversation

@samgbafa

@samgbafa samgbafa commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Linear: TC-4464. Canonical schema: TinyCloudLabs/tinycloud-dev-sam#393, merged as squash 69964051eaf7e8a0433c4deed3174450314d7730. log-shipper/canonical.json pins that commit; the fields.json bytes are unchanged (sha256 86312cc2…).

Review fixes (Bobbie): node_health::bounded makes a timed artifact_parts pass succeed only on Ok(Ok(_)), so a failed reap now counts as a failure (new unit test). The node-health interval uses MissedTickBehavior::Delay.

Since ~18:35Z 2026-11-28 prod /invoke runs 5–10x slower and CPU, pool state and job timings are not visible. This adds a fixed-rate health line and names the sqlx pool warnings.

Node

  • node_health.rs: once a minute (tinycloud::node_health), node health with 21 integer fields: interval, process CPU user/sys ms (getrusage delta), RSS, tokio workers/tasks/global queue/busy ms, in-flight requests now and max in the minute, pool max/size/idle/in_use/waiting, and since the last line pool acquired/timed_out/cancelled/failed, total and longest acquire wait.
  • One node job health line per job that has run: job (artifact_parts, renewal, replay_cleanup, kv_orphans, retention, webhook_dispatch), runs, failures, last_ms, max_ms, running_ms.
  • In-flight: a guard in the request's local_cache (dropped with the request).
  • Counts and durations only: no SQL, URIs, DIDs, space ids, keys or paths.

Vendored sqlx (vendor/sqlx-core/PATCH.md)

  • Pool::acquire_stats() / Pool::take_acquire_wait_max(): per-pool counters for each acquisition outcome, waiters and wait time.
  • The warnings "closing a pooled connection released inside a transaction" and "acquired connection, but time to acquire exceeded slow threshold" now log on target tinycloud_core::db_pool. Before, may_be_logged dropped every sqlx* target in-process, so neither line was ever written. The sqlx* filter is unchanged.

Log shipper

  • node_health / node_job_health ship individually, validated key by key in sanitize.vrl (exact key sets, integer bounds, job from the schema enum).
  • diagnostics.json: db_pool_closed_in_transaction (existing canonical code, TC-2954/TC-3006) and the new db_pool_acquire_slow.
  • Volume: at most 7 events/min = 10,080/day. Worst case 2,238 bytes/min (96,681,600 bytes per 30 days NDJSON); realistic ~1,520 bytes/min.

Compose / N0

VECTOR_CONFIG_JSON is regenerated in docker-compose.dstack-postgres.yaml and scripts/ci/fixtures/tc959-n0-compose.yaml. The regeneration procedure reproduces main's line byte-exactly. Rebased on #769 (a0e2ddc, TC-4466 cloudflared restart line kept as merged), the N0 template hash moves 0391bb7d… → 86ffe6b3be75877b3a35dee1ab42a073860c370c09536148c0dd9b89b7859ba2 (raw 53a78d72e291efa6f588f0e0ef308211ede3a214360671a07b405a637875e7d7), in docker.yml, docs/releasing.md and CHANGELOG.

Overlap: #606 (TC-3006, open) retargets the same tx-release warning with an exact mapping. This PR does not touch #606. If #606 lands after this, it must reconcile with it: the warning's target is already tinycloud_core::db_pool and it maps to db_pool_closed_in_transaction as a scoped entry here, and the regenerated compose and N0 hash must be redone.

Verification

  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings
  • cargo test -p tinycloud-node --lib (1201 pass), cargo test -p tinycloud-core --test sqlx_request_telemetry (18 pass)
  • node --test log-shipper/budget.test.mjs log-shipper/profile.test.mjs log-shipper/ledger.test.mjs log-shipper/ledger-start.test.mjs scripts/tc959-docker.test.mjs scripts/tc959-readiness.test.mjs (55 pass)
  • node scripts/tc959-check.mjs passes
  • Vector 0.59.0 vector test, errors_slow and all_requests: 531/531 pass each, including 29 health and pool-code cases.
  • A throwaway Rocket smoke test confirmed that in-flight returns to 0 after the responses drop. It also captured a real row:
{"level":"INFO","fields":{"message":"node health","interval_ms":31,"cpu_user_ms":0,"cpu_sys_ms":0,"rss_bytes":48029696,"tokio_workers":2,"tokio_tasks":1,"tokio_global_queue":0,"tokio_busy_ms":0,"in_flight":0,"in_flight_max":1,"pool_max":1,"pool_size":1,"pool_idle":1,"pool_in_use":0,"pool_waiting":0,"pool_acquired":0,"pool_timed_out":0,"pool_cancelled":0,"pool_failed":0,"pool_wait_total_ms":0,"pool_wait_max_ms":0},"target":"tinycloud::node_health"}
{"level":"INFO","fields":{"message":"node job health","job":"kv_orphans","runs":1,"failures":0,"last_ms":31,"max_ms":31,"running_ms":0},"target":"tinycloud::node_health"}

@samgbafa
samgbafa force-pushed the skgbafa/tc-4464-node-health-telemetry branch from 5366780 to 8b8b4d2 Compare November 28, 2026 22:29
- node_health: one `node health` line a minute (CPU user/sys delta, RSS, tokio, in-flight, DB pool state and acquire counters) and one `node job health` line per background job that ran; counts and durations only.
- vendored sqlx-core: Pool::acquire_stats()/take_acquire_wait_max(); the tx-release and slow-acquire warnings log on tinycloud_core::db_pool (sqlx* targets were dropped in-process).
- log shipper: node_health/node_job_health events validated key by key; db_pool_closed_in_transaction and db_pool_acquire_slow codes; canonical schema pin bd108145 (tinycloud-dev-sam#393).
- compose: regenerated VECTOR_CONFIG_JSON; N0 template hash 5a7bcad6… (raw 7675e6a1…).

Linear: TC-4464
@samgbafa
samgbafa force-pushed the skgbafa/tc-4464-node-health-telemetry branch from 8b8b4d2 to 508807a Compare November 28, 2026 22:58
@samgbafa

Copy link
Copy Markdown
Contributor Author

Rebased onto a0e2ddc (#769, TC-4466). Its cloudflared restart: ${CLOUDFLARE_TUNNEL_TOKEN:+unless-stopped} line is kept. The N0 lock was regenerated: template 86ffe6b3be75877b3a35dee1ab42a073860c370c09536148c0dd9b89b7859ba2 (raw 53a78d72…), was 0391bb7d….

Note for #606 (TC-3006): it is left untouched. If it lands after this PR, it must reconcile with it. Here the tx-release warning already logs on tinycloud_core::db_pool and maps to db_pool_closed_in_transaction via a scoped diagnostics entry, and #606 would also need to regenerate VECTOR_CONFIG_JSON and the N0 hash.

…health ticks

- node_health::bounded: a timed pass succeeds only on Ok(Ok(_)); artifact_parts used the outer timeout result, so an inner reap error counted as a success.
- The node-health interval uses MissedTickBehavior::Delay, so a stall does not emit back-to-back rows with interval_ms near 0.

Linear: TC-4464
…#393 squash)

- fields.json bytes unchanged (sha256 86312cc2…); revision only.

Linear: TC-4464
@samgbafa
samgbafa merged commit c061ff4 into main Nov 28, 2026
38 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant