-
Notifications
You must be signed in to change notification settings - Fork 0
perf(clickhouse): stop storing native event attributes #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: qa/agent-triggerdotdev-trigger-dev/pr-14-4866/base
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| -- +goose Up | ||
|
|
||
| -- Full-text search is served outside the source event table. Keeping these | ||
| -- indexes here adds work to every event insert and merge without serving reads. | ||
| ALTER TABLE trigger_dev.task_events_v2 | ||
| DROP INDEX IF EXISTS idx_attributes_text_search; | ||
|
|
||
| ALTER TABLE trigger_dev.task_events_v2 | ||
| DROP INDEX IF EXISTS idx_message_text_search; | ||
|
|
||
| -- attributes remains an insert input for attributes_text, but is no longer | ||
| -- stored. Writers must include attributes in an explicit insert column list | ||
| -- because implicit INSERT column lists exclude EPHEMERAL columns. | ||
| ALTER TABLE trigger_dev.task_events_v2 | ||
| MODIFY COLUMN attributes JSON EPHEMERAL; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shipwright · CRITICAL The migration makes 'attributes' EPHEMERAL, which means it is not stored. Impact: The migration makes 'attributes' EPHEMERAL, which means it is not stored. Any existing writer that uses implicit INSERT column lists (i.e., INSERT without an explicit column list) will now silently fail or misbehave because EPHEMERAL columns are excluded from implicit column lists. The comment acknowledges this, but the migration does not verify or coordinate that all writers have been updated before applying the sc… Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright. |
||
|
|
||
| -- +goose Down | ||
|
|
||
| -- Restoring the stored JSON column safely requires inspecting the live schema | ||
| -- and coordinating the writer rollback. Use a new forward migration instead. | ||
| SELECT throwIf(1, 'This migration cannot be rolled back automatically'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shipwright · CRITICAL The Down migration intentionally throws, making rollback impossible. Impact: The Down migration intentionally throws, making rollback impossible. If the Up migration is applied and then a writer incompatibility or data-loss issue is discovered, there is no automated path to restore the previous schema. This is a release-stopping operational risk for a storage-affecting change. Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,49 @@ describe("task events v2", () => { | |
| has_inserted_at: 1, | ||
| }, | ||
| ]); | ||
|
|
||
| const readColumnKinds = ch.reader.query({ | ||
| name: "read-task-event-attribute-column-kinds", | ||
| query: `SELECT name, default_kind, default_expression | ||
| FROM system.columns | ||
| WHERE database = 'trigger_dev' | ||
| AND table = 'task_events_v2' | ||
| AND name IN ('attributes', 'attributes_text') | ||
| ORDER BY name`, | ||
| schema: z.object({ | ||
| name: z.string(), | ||
| default_kind: z.string(), | ||
| default_expression: z.string(), | ||
| }), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shipwright · HIGH The test asserts 'default_expression' equals 'defaultValueOfTypeName('JSON')' for the EPHEMERAL column. Impact: The test asserts 'default_expression' equals 'defaultValueOfTypeName('JSON')' for the EPHEMERAL column. This couples the test to ClickHouse's internal default-expression representation, which is brittle across ClickHouse versions and makes the test fail for reasons unrelated to the intended behavior. Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright. |
||
| }); | ||
| const [columnError, columns] = await readColumnKinds({}); | ||
| expect(columnError).toBeNull(); | ||
| expect(columns).toEqual([ | ||
| { | ||
| name: "attributes", | ||
| default_kind: "EPHEMERAL", | ||
| default_expression: "defaultValueOfTypeName('JSON')", | ||
| }, | ||
| { | ||
| name: "attributes_text", | ||
| default_kind: "MATERIALIZED", | ||
| default_expression: "toJSONString(attributes)", | ||
| }, | ||
| ]); | ||
|
|
||
| const readRemovedIndexes = ch.reader.query({ | ||
| name: "read-removed-task-event-text-indexes", | ||
| query: `SELECT name | ||
| FROM system.data_skipping_indices | ||
| WHERE database = 'trigger_dev' | ||
| AND table = 'task_events_v2' | ||
| AND name IN ('idx_attributes_text_search', 'idx_message_text_search') | ||
| ORDER BY name`, | ||
| schema: z.object({ name: z.string() }), | ||
| }); | ||
| const [indexError, indexes] = await readRemovedIndexes({}); | ||
| expect(indexError).toBeNull(); | ||
| expect(indexes).toEqual([]); | ||
| } | ||
| ); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shipwright · HIGH
Dropping 'idx_attributes_text_search' and 'idx_message_text_search' removes full-text search indexes.
Impact: Dropping 'idx_attributes_text_search' and 'idx_message_text_search' removes full-text search indexes. If any read path still queries these columns with text-search operators, performance will degrade severely or queries may fail. The migration does not verify that no remaining readers depend on these indexes.
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.