Skip to content
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

Fix multiple data sources for a single conversation #11509

Merged
merged 4 commits into from
Mar 20, 2025

Conversation

Fraggle
Copy link
Contributor

@Fraggle Fraggle commented Mar 20, 2025

Description

Enforce unique index, add distributed lock, create backfill script.

Tests

Run locally (i had duplicates)

Risk

Low

Deploy Plan

Run backfill, apply migration, deploy front

@Fraggle Fraggle requested a review from flvndvd March 20, 2025 18:08
Copy link

github-actions bot commented Mar 20, 2025

Warnings
⚠️

Files in **/lib/models/ have been modified and the PR has the migration-ack label. Don't forget to run the migration from prodbox.

Generated by 🚫 dangerJS against 8086f25

@Fraggle Fraggle added the migration-ack 📁 Label to acknowledge that a migration is required. label Mar 20, 2025
Copy link
Contributor

@flvndvd flvndvd left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1,45 +1,37 @@
export class Lock {
private static locks = new Map<string, Promise<void>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

So wait the issue stems from the fact that the lock was in memory rather than on Redis?

@@ -0,0 +1,6 @@
DROP INDEX CONCURRENTLY "data_sources_workspace_id_conversation_id";
Copy link
Contributor

Choose a reason for hiding this comment

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

So we drop the index before creating the new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, seems that we can't update.

"Successfully processed file"
);
} catch (error) {
logger.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't want to throw/exit if we hit those errors? I guess if we have a lot of volume, those errors might end up being "unnoticed".

continue;
}

await hardDeleteDataSource(tempAuth, ds);
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to soft delete them first!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really ? Why ? (it was working just fine in my test)

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, we had a check to ensure data sources were soft deleted first.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at the soft delete, it does delete directly the data source view, to ensure it's not visible anymore in the product:

protected async softDelete(

Copy link
Contributor

Choose a reason for hiding this comment

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

Also it's probably best, to simply use the softDeleteDataSourceAndLaunchScrubWorkflow.

@Fraggle Fraggle merged commit 849240d into main Mar 20, 2025
7 checks passed
@Fraggle Fraggle deleted the 2428-multiple-data-sources-for-a-single-conversation branch March 20, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration-ack 📁 Label to acknowledge that a migration is required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants