Fix analytics CDC recovery follow-up - #1320
Conversation
Split dbt into activity and sleep/dashboard phases so deduped_activities keeps refreshing, and replace sleep_heart_rate_sample microbatch with dirty-key incremental updates. Co-authored-by: Cursor <cursoragent@cursor.com>
…activities # Conflicts: # docs/production-incident-baseline.md
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
📝 WalkthroughWalkthroughTwo production incident fixes from 2026-06-19: (1) ChangesClickHouse CDC this-binding fix and destination truncation
deduped_activities SELECT column reorder
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
Storybook previews for This comment updates automatically on each PR push. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@analytics/models/read_models/read_model_microbatch.sql.test.ts`:
- Around line 137-142: The two expect(normalizedSql).toContain() assertions in
the test are validating an incorrect column order that does not match the actual
production ClickHouse schema. According to the schema,
absent_source_external_ids should appear at position 16 (before
member_activity_ids), not after refreshed_at. Update both expect statements to
verify the correct column sequence where source_external_ids comes first,
followed by absent_source_external_ids, then member_activity_ids, and the
remaining columns in their proper order.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: dcdef84a-dca5-4cc5-9f72-67f9cda53356
📒 Files selected for processing (5)
analytics/models/read_models/deduped_activities.sqlanalytics/models/read_models/read_model_microbatch.sql.test.tsdocs/production-incident-baseline.mdsrc/db/clickhouse-cdc.test.tssrc/db/clickhouse-cdc.ts
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You’re at about 95% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Requires human review: This PR modifies change data capture (CDC) and analytics read-model logic, including ClickHouse client binding fixes, table truncation for mirror recreation, and SQL column reordering. These changes touch production data infrastructure and could cause data loss or corruption if incorrect.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 7 files (changes from recent commits).
You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Requires human review: Changes include database schema migration (dropping and recreating tables), core CDC data pipeline logic modifications, and production infrastructure recovery. These are high-risk operations affecting data integrity and production systems.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Requires human review: Contains a ClickHouse migration that drops and recreates analytics.deduped_activities, plus new truncation logic in CDC setup. Both are medium-risk changes requiring human review for correctness and production impact.
Re-trigger cubic
Summary
Validation
Production verification
Summary by cubic
Fixes analytics CDC recovery by preserving ClickHouse client method binding and truncating the correct ClickHouse destinations before recreating missing mirrors. Normalizes
analytics.deduped_activitiescolumn order and adds migration and test coverage to prevent regressions.Bug Fixes
clickHouseClient.querybinding to avoid@clickhouse/client-commonTypeError; add a regression test that assertsthisis bound with a context-aware client.do_initial_copy = true; add tests that verify table-specific truncation in both absent and existing mirror cases.deduped_activitiesincremental SELECT in canonical order; strengthen tests to assert emitted column order fragments.Migration
0033_recreate_deduped_activities_column_order(using exported canonical SQL) to drop and recreateanalytics.deduped_activities; register it and update tests to expect 33 migrations.Written for commit 42bf911. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests
Documentation