perf: optimize database pools, batch commits, and node health checks#615
Open
wahh3b-lgtm wants to merge 1 commit into
Open
perf: optimize database pools, batch commits, and node health checks#615wahh3b-lgtm wants to merge 1 commit into
wahh3b-lgtm wants to merge 1 commit into
Conversation
- DB pool: increase pool_recycle to 1800s, add pool_timeout (default 15s), enable pool_use_lifo, add ge=1 validation - Alembic migration: add performance indexes (status/expire, status/used_traffic, nodes/status, hosts/inbound_tag, etc.) - Indexes defined in models (__table_args__) so Alembic detects changes properly - Record usages: cache dialect lookup with double-checked locking, per-node safe_execute - Node health checks: concurrent asyncio.gather with snapshot revalidation and exception logging - XRayConfig: revert TLS reads to synchronous (run_until_complete fails on running loop) - Update .env.example with new pool defaults
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
config.py,app/db/base.py): Increasedpool_recycleto 1800s, added configurablepool_timeout(default 15s) withge=1validation, enabledpool_use_lifo=True(status, expire),(status, used_traffic),(nodes.status),(hosts.inbound_tag),(hosts.is_disabled),(notification_reminders.user_id)__table_args__so Alembic can detect and manage them automaticallyapp/jobs/record_usages.py): Cached dialect lookup with double-checked locking to prevent race conditions. Per-nodesafe_executefor node statsapp/node/__init__.py): Concurrentasyncio.gather()with snapshot revalidation and exception logging for failed probesapp/core/xray.py): Reverted TLS reads to synchronous (run_until_completeon a running loop always raisedRuntimeError)Files Changed
config.pyapp/db/base.pyapp/db/__init__.pyapp/db/models.pyapp/db/migrations/versions/118c2a5eaa7d_add_performance_indexes.py(new)app/jobs/record_usages.pyapp/node/__init__.pyapp/core/xray.py.env.exampleVerification