feat(storage): add CitusStorageBackend for distributed PostgreSQL#238
feat(storage): add CitusStorageBackend for distributed PostgreSQL#238yasha-dev1 merged 3 commits intomainfrom
Conversation
Adds a new CitusStorageBackend that extends PostgresStorageBackend, reusing all query logic while overriding schema initialization to create Citus-compatible distributed tables (composite PKs, no cross-shard FKs, reference table for schema_versions). Distribution strategy: - workflow_runs, events, steps, hooks, cancellation_flags: sharded on run_id - schedules: sharded on schedule_id - schema_versions: reference table (replicated to all workers) Enables PYWORKFLOW_STORAGE_TYPE=citus using the existing PYWORKFLOW_POSTGRES_* env vars. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔍 Code Review Agent — Tier 2Commit: Now I have a thorough understanding of the PR. Here is the code review: SummaryThis PR adds Risk AssessmentTier 2 is appropriate. All changed files are in Issues1. (warning) 2. (warning) ArchitectureThe dependency rule ( Test CoverageThe unit tests are well-structured and cover the key non-live paths: constructor parameters, inheritance assertions, 🤖 Code Review Agent — automated code review. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
🔄 New commits pushed — requesting re-review. Commit: |
🔍 Code Review Agent — Tier 2Commit: Now I have a complete picture of the changes. Let me write the review. SummaryThis PR adds Risk AssessmentTier 2 is correct. The changes add a new storage backend without touching any Tier 3 files ( Issues
ArchitectureThe changes comply with the dependency rules. Test CoverageTests cover initialization parameters, DSN handling, inheritance assertions, config serialization round-trips, and env var loading. These are adequate for the configuration-layer changes. However, the core Citus-specific logic — 🤖 Code Review Agent — automated code review. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
🔄 New commits pushed — requesting re-review. Commit: |
🔍 Code Review Agent — Tier 2Commit: Now I have enough information to write a complete review. Code Review: CitusStorageBackendSummaryThis PR adds a Risk AssessmentTier 2 — confirmed. Changes are confined to Issues
ArchitectureCompliant. Test CoverageAdequate for config plumbing (serialization, env-var loading, cache behavior, round-trips). Insufficient for the core Citus-specific logic: schema initialization, table distribution, and the migration runner's Citus branch are entirely untested at the unit level. 🤖 Code Review Agent — automated code review. |
Summary
CitusStorageBackendthat extendsPostgresStorageBackend, reusing all query logic and only overriding_initialize_schema()to produce Citus-compatible DDLCitusMigrationRunnerthat extendsPostgresMigrationRunnerto handle V2 migration without adding cross-shard-incompatible UNIQUE constraintsPYWORKFLOW_STORAGE_TYPE=citusenv var support (reuses existingPYWORKFLOW_POSTGRES_*vars)Schema changes vs plain PostgreSQL
eventsevent_id→(run_id, event_id)stepsstep_id→(run_id, step_id)+ shard-localidx_steps_step_idworkflow_runsparent_run_idFK dropped;idempotency_keyunique index → plain indexhooksUNIQUEontoken→ plain indexcancellation_flagsrun_iddroppedschema_versionsDistribution:
workflow_runs,events,steps,hooks,cancellation_flagsco-located onrun_id;schedulesdistributed onschedule_id. Table distribution is idempotent (usespg_classjoin onpg_dist_partitionto skip already-distributed tables).Risk tier
Tier 2 — new storage backend (additive); no changes to existing backends, engine, or executor.
Test plan
storage_to_config()round-trips,config_to_storage(), caching, and env-var loadingruff checkcleanmypy— no new errors in changed files🤖 Generated with Claude Code