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

feat: Add database cleanup functions for transactions and vertex builds #4694

Merged
merged 8 commits into from
Nov 19, 2024

Conversation

ogabrielluiz
Copy link
Contributor

This pull request introduces functions to clean up old transactions and vertex builds in the database, ensuring that only a configured maximum number of each is retained. The clean_transactions function deletes transactions exceeding the specified limit, while clean_vertex_builds performs a similar cleanup for vertex builds. Additionally, these cleanup functions are integrated into the service initialization process, and new configuration options for maximum retention limits have been added.

@ogabrielluiz ogabrielluiz requested a review from NadirJ November 19, 2024 00:56
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Nov 19, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 19, 2024
Copy link

codspeed-hq bot commented Nov 19, 2024

CodSpeed Performance Report

Merging #4694 will degrade performances by 95.84%

Comparing transaction-vb-limit (dc4f6ba) with main (b978241)

Summary

⚡ 1 improvements
❌ 5 regressions
✅ 9 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main transaction-vb-limit Change
test_create_starter_projects 1.2 s 1.6 s -19.91%
test_initialize_services 424.3 ms 708.2 ms -40.08%
test_initialize_super_user 670.7 ms 954.5 ms -29.73%
test_successful_run_with_input_type_text 217.6 ms 140.6 ms +54.74%
test_successful_run_with_output_type_any 219.5 ms 5,274.6 ms -95.84%
test_successful_run_with_output_type_debug 162.7 ms 295.3 ms -44.91%

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 19, 2024
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) November 19, 2024 21:23
…atabase

- Implement `clean_transactions` to delete transactions exceeding the configured limit.
- Implement `clean_vertex_builds` to delete vertex builds exceeding the configured limit.
- Integrate cleanup functions into the service initialization process.
- Wrap transaction and vertex build cleanup operations in try-except blocks.
- Log success and error messages for cleanup operations.
- Rollback session on exceptions without re-raising, as these are cleanup tasks.
- Adjust service initialization order to ensure proper setup.
@ogabrielluiz ogabrielluiz merged commit a0acf39 into main Nov 19, 2024
19 checks passed
@ogabrielluiz ogabrielluiz deleted the transaction-vb-limit branch November 19, 2024 23:16
mieslep pushed a commit to mieslep/langflow that referenced this pull request Nov 22, 2024
…ds (langflow-ai#4694)

* feat: Add configuration options for maximum transactions and vertex builds retention

* Add functions to clean up old transactions and vertex builds in the database

- Implement `clean_transactions` to delete transactions exceeding the configured limit.
- Implement `clean_vertex_builds` to delete vertex builds exceeding the configured limit.
- Integrate cleanup functions into the service initialization process.

* Add error handling and logging for cleanup tasks in utils.py

- Wrap transaction and vertex build cleanup operations in try-except blocks.
- Log success and error messages for cleanup operations.
- Rollback session on exceptions without re-raising, as these are cleanup tasks.
- Adjust service initialization order to ensure proper setup.

* Reorder setup and cleanup tasks in database initialization process

* fix: Update type hints for settings_service in cleanup functions

* Remove execution options in cleanup functions

* Handle specific exceptions during cleanup tasks in utils.py

* Use `col` for column references in delete statements to improve SQL query clarity.
diogocabral pushed a commit to headlinevc/langflow that referenced this pull request Nov 26, 2024
…ds (langflow-ai#4694)

* feat: Add configuration options for maximum transactions and vertex builds retention

* Add functions to clean up old transactions and vertex builds in the database

- Implement `clean_transactions` to delete transactions exceeding the configured limit.
- Implement `clean_vertex_builds` to delete vertex builds exceeding the configured limit.
- Integrate cleanup functions into the service initialization process.

* Add error handling and logging for cleanup tasks in utils.py

- Wrap transaction and vertex build cleanup operations in try-except blocks.
- Log success and error messages for cleanup operations.
- Rollback session on exceptions without re-raising, as these are cleanup tasks.
- Adjust service initialization order to ensure proper setup.

* Reorder setup and cleanup tasks in database initialization process

* fix: Update type hints for settings_service in cleanup functions

* Remove execution options in cleanup functions

* Handle specific exceptions during cleanup tasks in utils.py

* Use `col` for column references in delete statements to improve SQL query clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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.

2 participants