Skip to content

Fix rename index collides with existing v2 index#16560

Merged
prastoin merged 1 commit intomainfrom
fix-rename-index-v3
Dec 15, 2025
Merged

Fix rename index collides with existing v2 index#16560
prastoin merged 1 commit intomainfrom
fix-rename-index-v3

Conversation

@prastoin
Copy link
Copy Markdown
Contributor

@prastoin prastoin commented Dec 15, 2025

Introduction

When migrating a v1 index name to v2 it might collide with an existing v2 index
In this case we remove both the v1 metadata and pg index

In case of a metadata and pg_index desync this might occur too late in the process that's why we have two fallback
One computing the v1 deletion from the metadata and another one in the catch block of the v1 to migration transaction commit

@prastoin prastoin marked this pull request as ready for review December 15, 2025 09:55
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-rename-index.command.ts">

<violation number="1" location="packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-rename-index.command.ts:173">
P1: Missing transaction for delete+drop operations in 42P07 error handler. Unlike the earlier block (lines 100-121) which wraps the same two operations in a transaction, this error handler performs them without atomicity guarantees. If `DROP INDEX` fails after metadata deletion succeeds, the database will be in an inconsistent state.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@prastoin prastoin merged commit 8c79353 into main Dec 15, 2025
60 of 63 checks passed
@prastoin prastoin deleted the fix-rename-index-v3 branch December 15, 2025 10:06
@twenty-eng-sync
Copy link
Copy Markdown

Hey @prastoin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

prastoin added a commit that referenced this pull request Dec 15, 2025
## Introduction
When migrating a v1 index name to v2 it might collide with an existing
v2 index
In this case we remove both the v1 metadata and pg index

In case of a metadata and pg_index desync this might occur too late in
the process that's why we have two fallback
One computing the v1 deletion from the metadata and another one in the
catch block of the v1 to migration transaction commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants