Skip to content

perf(clickhouse): prepare task event attribute inserts - #4860

Merged
carderne merged 2 commits into
mainfrom
perf/clickhouse-event-storage-tri-13550
Sep 2, 2026
Merged

perf(clickhouse): prepare task event attribute inserts#4860
carderne merged 2 commits into
mainfrom
perf/clickhouse-event-storage-tri-13550

Conversation

@carderne

@carderne carderne commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Prepare task event writes for a later storage schema change without changing the table itself. Event attributes continue to be stored and read exactly as before.

Design

The event writer now names every insert column explicitly, ensuring attributes remains part of the input when the column becomes input-only. The remaining native attribute-path queries read the existing attributes_text representation through JSON extraction functions.

This PR does not alter the task_events_v2 schema.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 113b0d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 26fcea43-ba0a-4348-8384-3814ae2cd648

📥 Commits

Reviewing files that changed from the base of the PR and between d6b02fa and 113b0d6.

📒 Files selected for processing (1)
  • internal-packages/clickhouse/src/taskEvents.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (30)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (7)
We use vitest exclusively.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
**Prefer static imports over dynamic imports.**

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
Add crumbs as you write code — not just when debugging.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
Use vitest for all tests in the Trigger.dev repository

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
Use function declarations instead of default exports

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
Use types over interfaces for TypeScript Avoid using enums; prefer string unions or const objects instead

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs Do not use high-cardinality attributes in OTEL metr...

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

Files:

  • internal-packages/clickhouse/src/taskEvents.test.ts
🔇 Additional comments (1)
internal-packages/clickhouse/src/taskEvents.test.ts (1)

14-15: LGTM!

Also applies to: 25-25, 39-39


Walkthrough

The ClickHouse writer now accepts explicit insert columns. The task events V2 path supplies all 18 target columns. Integration tests verify nested attribute serialization and automatic inserted_at population. Administrative queries and JSON recovery tests now read and extract values from attributes_text directly.

Merge Risk: 🔵 Low · up to 113b0

The PR makes task-event inserts explicit and changes selected administrative reads to extract JSON from the persisted representation without changing the schema. Normal behavior remains covered, but merge should proceed with owner awareness of the bounded rollback-safety concern and the required implementation-documentation follow-up.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description accurately explains the ClickHouse insert and attribute query changes, but it omits the required issue reference, checklist, testing details, changelog, and screenshots sections from t… Add the missing template sections. Include the issue reference, completed checklist, exact testing steps and results, a short changelog entry, and screenshots or an explicit statement that screenshots are not applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the ClickHouse task event insert preparation, which is the primary change in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description accurately explains the ClickHouse insert and attribute query changes, but it omits the required issue reference, checklist, testing details, changelog, and screenshots sections from the repository template.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/clickhouse-event-storage-tri-13550

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 30ed0661-455b-487e-bf67-ab7f7e087936

📥 Commits

Reviewing files that changed from the base of the PR and between 43ecf15 and 9fc88e0.

📒 Files selected for processing (7)
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/schema/042_reduce_task_events_v2_storage_overhead.sql
  • internal-packages/clickhouse/src/client/client.ts
  • internal-packages/clickhouse/src/client/types.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
  • internal-packages/clickhouse/src/taskEvents.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout. (29)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (14)
Never use `request.signal` to detect client disconnects. Use `getRequestAbortSignal()` from `app/services/httpAsyncStorage.server.ts`, which is wired to Express response close events.

📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)

Files:

  • apps/webapp/app/services/admin/missingLlmModels.server.ts
We use vitest exclusively. **Never mock anything** - use testcontainers instead.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
Test files must not import `app/env.server.ts`; pass configuration as options instead.

📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
For dashboard changes, visually verify the running Remix app with Chrome DevTools MCP, using snapshots, screenshots, interaction, and console-message checks as appropriate.

📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)

Files:

  • apps/webapp/app/services/admin/missingLlmModels.server.ts
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/client/types.ts
  • internal-packages/clickhouse/src/taskEvents.ts
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
  • internal-packages/clickhouse/src/client/client.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/client/types.ts
  • internal-packages/clickhouse/src/taskEvents.ts
  • internal-packages/clickhouse/schema/042_reduce_task_events_v2_storage_overhead.sql
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
  • internal-packages/clickhouse/src/client/client.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
Migration file numbering: name files as `0(N+1)_descriptive_name.sql` where N is the largest existing migration number in `schema/`; rebase and renumber if main adds migrations before opening a PR

📄 CodeRabbit inference engine (internal-packages/clickhouse/CLAUDE.md)

Files:

  • internal-packages/clickhouse/schema/042_reduce_task_events_v2_storage_overhead.sql
Use zod for validation in packages/core and apps/webapp

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
Do not import `env.server.ts` directly or indirectly into test files; instead pass environment-dependent values through options/parameters to make code testable

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
Access environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env`

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
Use vitest for all tests in the Trigger.dev repository

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
Use function declarations instead of default exports

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/client/types.ts
  • internal-packages/clickhouse/src/taskEvents.ts
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
  • internal-packages/clickhouse/src/client/client.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
Use types over interfaces for TypeScript

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/client/types.ts
  • internal-packages/clickhouse/src/taskEvents.ts
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
  • internal-packages/clickhouse/src/client/client.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

Files:

  • apps/webapp/test/clickhouseEventRepositoryJsonRecovery.test.ts
  • internal-packages/clickhouse/src/client/types.ts
  • internal-packages/clickhouse/src/taskEvents.ts
  • apps/webapp/app/services/admin/missingLlmModels.server.ts
  • internal-packages/clickhouse/src/client/client.ts
  • internal-packages/clickhouse/src/taskEvents.test.ts
🧠 Learnings (1)
📚 Learning: 2026-06-16T09:19:47.637Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3960
File: apps/webapp/test/prismaInfrastructureErrorCapture.test.ts:0-0
Timestamp: 2026-06-16T09:19:47.637Z
Learning: In this repo’s Vitest setup, `vitest.config.ts` uses `globals: true`, so identifiers like `vi`, `describe`, `it`, and `expect` are available as globals in Vitest test files. During code review, do not flag missing `vi`/`describe`/`it`/`expect` imports as a runtime error or correctness issue when they’re used in `*.test.ts/tsx` or `*.spec.ts/tsx` files. Explicit imports are still preferred for consistency, but they’re not required for runtime behavior.

Applied to files:

  • internal-packages/clickhouse/src/taskEvents.test.ts

Comment thread internal-packages/clickhouse/src/taskEvents.ts
@carderne carderne changed the title perf(clickhouse): reduce task event storage overhead perf(clickhouse): prepare task event attribute inserts Sep 1, 2026
@carderne
carderne force-pushed the perf/clickhouse-event-storage-tri-13550 branch from 9fc88e0 to d6b02fa Compare September 1, 2026 14:37
coderabbitai[bot]

This comment was marked as resolved.

@carderne
carderne marked this pull request as ready for review September 1, 2026 15:05

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@carderne
carderne added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 04d3264 Sep 2, 2026
55 checks passed
@carderne
carderne deleted the perf/clickhouse-event-storage-tri-13550 branch September 2, 2026 11:24
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.

2 participants