Skip to content

fix(db): recover failed credential group index on migration retry - #7595

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/credential-group-workspace-migration
Sep 8, 2026
Merged

fix(db): recover failed credential group index on migration retry#7595
waleedlatif1 merged 2 commits into
stagingfrom
fix/credential-group-workspace-migration

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Recover the invalid workspace credential-group index left by a failed concurrent build when migration 0326 is retried.
  • Preserve healthy indexes and existing data. Remaining duplicate groups still fail uniqueness validation.
  • Fix a flaky connector test to compare exact IDs instead of rejecting incidental substring matches in generated IDs.

Type of Change

  • Bug fix

Testing

Six PostgreSQL migration tests passed, covering duplicate failures, recovery after removing duplicates, interrupted recovery, and healthy-index preservation. All 58 connector orchestration tests passed. Database type checking, lint, all 46 audits, docs-manifest validation, and migration safety checks passed.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 8, 2026 3:19pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes migration 0326 recover automatically from an invalid workspace credential-group index left by a failed concurrent build.

  • Renames only the expected invalid index before dropping it concurrently.
  • Refuses to remove a valid or otherwise unexpected index occupying the recovery name.
  • Adds PostgreSQL coverage for duplicate-data retries, interrupted recovery, and healthy-index preservation.
  • Corrects a connector test to compare identifiers exactly.

Confidence Score: 5/5

The PR appears safe to merge; no outstanding correctness or repository-rule issue was identified.

The migration narrowly recovers the expected invalid index, rejects unexpected recovery-name occupants, retains concurrent index operations, and has focused replay coverage for its important failure states. The follow-up connector assertion remains safe and tests the intended identifier contract more precisely.

Important Files Changed

Filename Overview
packages/db/migrations/0326_enterprise_organization_search.sql Adds guarded, replay-safe recovery for the invalid workspace uniqueness index while preserving healthy indexes and existing rows.
packages/db/organization-search-migration.postgres.test.ts Expands PostgreSQL migration tests across duplicate failure, repaired retry, interrupted recovery, and healthy-index replay scenarios.
apps/sim/lib/knowledge/orchestration/connectors.test.ts Replaces substring matching with an exact connector-identifier inequality assertion.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Retry migration 0326] --> B{Recovery-named index exists?}
    B -- Yes --> C{Invalid and owned by credential_group?}
    C -- No --> D[Abort without dropping index]
    C -- Yes --> E[Continue recovery]
    B -- No --> E
    E --> F{Original workspace index is invalid?}
    F -- Yes --> G[Rename to recovery name]
    F -- No --> H[Preserve original index]
    G --> I[Drop recovery index concurrently]
    H --> I
    I --> J[Create workspace unique index concurrently if absent]
    J --> K{Duplicate workspace groups remain?}
    K -- Yes --> L[Uniqueness build fails; data remains]
    K -- No --> M[Valid unique index restored]
Loading

Reviews (2): Last reviewed commit: "fix(test): compare connector identifiers..." | Re-trigger Greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@TheodoreSpeaks I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1
waleedlatif1 merged commit 90adc4e into staging Sep 8, 2026
33 of 34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/credential-group-workspace-migration branch September 8, 2026 15:23
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