Skip to content

perf(clickhouse): stop storing native event attributes - #4866

Merged
carderne merged 1 commit into
mainfrom
perf/clickhouse-ephemeral-attributes-tri-13550
Sep 2, 2026
Merged

perf(clickhouse): stop storing native event attributes#4866
carderne merged 1 commit into
mainfrom
perf/clickhouse-ephemeral-attributes-tri-13550

Conversation

@carderne

@carderne carderne commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stop storing native JSON event attributes while retaining the existing materialized attributes_text representation. Also remove the two unused full-text indexes from the source event table.

Design

This depends on #4860. Its explicit-column writer must be deployed before this migration is applied so attributes continue to feed the materialized string.

The JSON input becomes EPHEMERAL, eliminating its stored subcolumns and merge overhead for new parts. Existing parts retain their JSON files until normal merges or TTL removal.

The migration is intentionally not reversible automatically. Restoring native JSON storage safely requires inspecting the current schema and coordinating the writer change, so it should be done with a new forward migration rather than a retry-sensitive Down migration.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c0fbe91

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

Walkthrough

The pull request adds a ClickHouse migration for trigger_dev.task_events_v2. It removes two data-skipping indexes and changes attributes to JSON EPHEMERAL. The migration blocks automatic rollback. The task events test verifies the column definitions and confirms that both indexes are absent.

Merge Risk: ⚪ Minimal · up to c0fbe

The migration stops storing native event attributes while preserving the materialized text representation and removes unused indexes; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the migration, design, dependency on #4860, data behavior, and rollback strategy. It does not follow the required template because it omits the issue reference, checklist, tes… Add the required template sections. Include the issue reference, completed checklist items, specific testing steps and results, a short changelog entry, and screenshots or an explicit indication that screenshots are not applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: stopping storage of native event attributes in ClickHouse. It is concise and uses the repository convention.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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 explains the migration, design, dependency on #4860, data behavior, and rollback strategy. It does not follow the required template because it omits the issue reference, checklist, testing steps, changelog, and screenshots sections.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 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-ephemeral-attributes-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.

@carderne
carderne marked this pull request as ready for review September 1, 2026 15:06
devin-ai-integration[bot]

This comment was marked as resolved.

@carderne
carderne force-pushed the perf/clickhouse-ephemeral-attributes-tri-13550 branch from e6f1300 to 9b86819 Compare September 2, 2026 08:11
devin-ai-integration[bot]

This comment was marked as resolved.

Base automatically changed from perf/clickhouse-event-storage-tri-13550 to main September 2, 2026 11:24
@carderne
carderne force-pushed the perf/clickhouse-ephemeral-attributes-tri-13550 branch from 9b86819 to c0fbe91 Compare September 2, 2026 11:24

@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 found 1 new potential issue.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@c0fbe91

trigger.dev

npm i https://pkg.pr.new/trigger.dev@c0fbe91

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@c0fbe91

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@c0fbe91

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@c0fbe91

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@c0fbe91

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@c0fbe91

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@c0fbe91

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@c0fbe91

commit: c0fbe91

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

🧹 Nitpick comments (1)
internal-packages/clickhouse/src/taskEvents.test.ts (1)

80-93: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add an insert/read assertion for attributes_text.

These metadata assertions can pass even when TASK_EVENT_V2_INSERT_COLUMNS omits attributes. Insert a representative event through insertTaskEventsV2, read attributes_text, and assert that it contains the input attributes. This prevents silent data loss when the migration is applied before #4860.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: e5316a18-a3b3-448f-b438-198775333395

📥 Commits

Reviewing files that changed from the base of the PR and between 04d3264 and c0fbe91.

📒 Files selected for processing (2)
  • internal-packages/clickhouse/schema/042_reduce_task_events_v2_storage_overhead.sql
  • 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.

📜 Review details
⏰ Context from checks skipped due to timeout. (33)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Build and publish previews
🧰 Additional context used
📓 Path-based instructions (8)
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/schema/042_reduce_task_events_v2_storage_overhead.sql
  • 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 DDL in migrations must be idempotent: use `...

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

Files:

  • internal-packages/clickhouse/schema/042_reduce_task_events_v2_storage_overhead.sql
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 (4)
internal-packages/clickhouse/schema/042_reduce_task_events_v2_storage_overhead.sql (3)

17-21: LGTM!


8-9: 🩺 Stability & Availability

No change required for replicated ALTER ordering.

trigger_dev.task_events_v2 uses MergeTree, and the migration runner executes Goose directly against the configured ClickHouse URL. The repository defines no replicated engine or ON CLUSTER migration path, so this CANNOT_ASSIGN_ALTER scenario does not apply.


15-15: 🗄️ Data Integrity & Integration

No change needed. insertTaskEventsV2 passes TASK_EVENT_V2_INSERT_COLUMNS to ClickhouseWriter.insertUnsafe, and that list includes attributes. The writer therefore supplies the EPHEMERAL input used by attributes_text.

internal-packages/clickhouse/src/taskEvents.test.ts (1)

95-107: LGTM!

@carderne
carderne added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 7ad0d92 Sep 2, 2026
56 checks passed
@carderne
carderne deleted the perf/clickhouse-ephemeral-attributes-tri-13550 branch September 2, 2026 13:14
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