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

Accelerate migration #17088

Merged
merged 4 commits into from
Apr 9, 2025
Merged

Conversation

wanghan5
Copy link
Contributor

Summary

Using batch update to accelerate migration.

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Tip

Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Fixes #17087

Screenshots

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 29, 2025
@crazywoola crazywoola requested a review from Copilot March 29, 2025 06:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR speeds up data migration by implementing a batch update mechanism for plugin data migration and updating the SQL query for better performance.

  • Introduced a new class method migrate_db_records that retrieves and processes records in larger batches.
  • Changed the SQL query to use pagination with a last_id parameter and batch updates to improve migration speed.
Comments suppressed due to low confidence (2)

api/services/plugin/data_migration.py:152

  • [nitpick] Consider renaming the loop variable 'i' to a more descriptive name such as 'row' to improve readability.
for i in rs:

api/services/plugin/data_migration.py:170

  • [nitpick] The try/except block wrapping this simple string formatting operation appears redundant, as string formatting is unlikely to fail; consider removing the try/except or handling a more specific exception.
updated_value = f"{DEFAULT_PLUGIN_ID}/{provider_name}/{provider_name}"

@crazywoola
Copy link
Member

Please fix the lint errors. :) in this PR and previous one as well.

@wanghan5
Copy link
Contributor Author

Please fix the lint errors. :) in this PR and previous one as well.

Reformated @crazywoola

@wanghan5 wanghan5 requested a review from bowenliang123 March 30, 2025 07:36
@wanghan5 wanghan5 marked this pull request as draft April 1, 2025 07:00
@wanghan5 wanghan5 marked this pull request as ready for review April 3, 2025 09:11
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 9, 2025
@crazywoola crazywoola merged commit b5498a3 into langgenius:main Apr 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration took tool long time
3 participants