feat(webapp): route ClickHouse reads to an optional read replica#4081
Conversation
|
WalkthroughAdds configurable ClickHouse reader and runs-list endpoints with fallback behavior in the environment schema. Extends the ClickHouse factory with a 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…reads Runs list reads (dashboard list, runs list API, live reload, child-status counts) went through the shared standard client (CLICKHOUSE_URL). Add a dedicated runsList client type backed by RUNS_LIST_CLICKHOUSE_URL so this high-traffic read path can target a read replica without moving ingest or replication writes off CLICKHOUSE_URL. Falls back to CLICKHOUSE_URL when unset, so it is a no-op unless configured.
Read-only clients (logs, query, admin, runsList, engine, realtime) now fall back X_CLICKHOUSE_URL ?? CLICKHOUSE_READER_URL ?? CLICKHOUSE_URL, and the events client uses the reader/writer split so trace/span/log reads hit the replica while event + log inserts stay on the writer. Set CLICKHOUSE_READER_URL once to move all reads off the primary. Writes (events, replication, sessions_replication, standard) always stay on CLICKHOUSE_URL. No-op when CLICKHOUSE_READER_URL is unset.
The run detail page loads a small prev/next navigation list via NextRunListPresenter; point it at the runsList client too so all runs list reads use the same dedicated client.
The events client both inserts events and reads traces/spans/logs through one instance. Give it a dedicated reader URL so reads can move to a replica while inserts stay on EVENTS_CLICKHOUSE_URL. Unlike the read-only clients, it does not fall back to CLICKHOUSE_READER_URL: a write-capable client only moves reads on an explicit opt-in.
00bee0f to
0bef4ee
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
…fallback The events read client (EVENTS_READER_CLICKHOUSE_URL) opts in explicitly and does not fall back to CLICKHOUSE_READER_URL; the comment previously implied it did.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 42d39d9b-0983-4d94-8e84-271dc47debb8
📒 Files selected for processing (1)
.server-changes/clickhouse-read-replica.md
📜 Review details
⏰ Context from checks skipped due to timeout. (18)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
- GitHub Check: typecheck / typecheck
- GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: code-quality / code-quality
- GitHub Check: audit
- GitHub Check: audit
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-14T14:54:39.095Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3545
File: .server-changes/agent-view-sessions.md:10-10
Timestamp: 2026-05-14T14:54:39.095Z
Learning: In the `trigger.dev` repository, do not flag inconsistent dot vs slash notation in route/path strings inside `.server-changes/*.md` files. These markdown files are consumed verbatim into the changelog, so the mixed notation (e.g., `resources.orgs.../runs.$runParam/...`) is intentional and should be preserved as-is.
Applied to files:
.server-changes/clickhouse-read-replica.md
Summary
Adds optional configuration to send ClickHouse read traffic to a separate instance (for example a read replica) while writes stay on the primary
CLICKHOUSE_URL. This lets operators offload read load (runs list, traces, logs, queries) from the cluster that handles inserts. Fully backwards compatible: with nothing new set, every client resolves toCLICKHOUSE_URLexactly as before.What it adds
CLICKHOUSE_READER_URL(optional): a single reader endpoint that the read-only clients fall back to. Read clients resolve<own URL> ?? CLICKHOUSE_READER_URL ?? CLICKHOUSE_URL. The task-events client (which both inserts events and reads traces, spans, and logs) is built as a reader/writer pair so queries use the reader while inserts stay onCLICKHOUSE_URL.RUNS_LIST_CLICKHOUSE_URL(optional): a dedicated client for the runs list (dashboard list, runs list API, live reload, child-status counts), so the highest-traffic read path can target its own instance.Safety
Only read-only clients fall back to the reader: logs, query, admin, runs list, the pending-version lookup, and the realtime run-id resolver. The query page is constrained to read-only (the TSQL parser rejects anything that is not a
SELECT, and areadonlysetting is applied). The task-events client routes inserts to the writer and queries to the reader per method, so a write can never reach the reader. Pure-write clients (event inserts, replication) always useCLICKHOUSE_URL.Note: this PR targets a baseline branch rather than
mainso the diff stays scoped to the read-replica changes. It will be retargeted tomainbefore merge.