fix(): Improve Connection Pool Reliability & Performance - #41
Open
Arielpetit wants to merge 1 commit into
Open
Conversation
Author
|
@MCVitzz @Cenuon @MowlCoder Can you please review this PR? |
abeni16
reviewed
Jul 31, 2026
abeni16
left a comment
Collaborator
There was a problem hiding this comment.
Tests and CI not covering concurrency or cross-engine behavior
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.
PR Description: Improve Connection Pool Reliability & Performance
Overview
This PR improves VeloxDB's connection management by fixing inconsistent error handling across database engines and optimizing connection pool cleanup. These changes improve reliability, reduce silent failures, and significantly speed up connection cleanup under heavy workloads.
Issues Addressed
1. Standardized Connection Pool Error Handling
Problem
The
refresh_connection_poolsfunction returnedResult<(), VeloxError>, but some database engines (MongoDB, DuckDB, and Redis) returned()instead of propagating errors correctly.This caused refresh operations to fail silently and made debugging difficult.
Root Cause
Error handling was implemented inconsistently across supported database engines. Some engines converted failures into generic values rather than returning structured
VeloxErrorinstances.Solution
Updated all affected database engines to return consistent
Result<(), VeloxError>values.Errors are now categorized as connection errors and propagated correctly throughout the application.
Behavior Change
Before
After
Result<(), VeloxError>.Impact
2. Optimized Connection Pool Cleanup
Problem
The
drop_poolfunction acquired multiple write locks sequentially during connection cleanup.With many active connections, this increased lock contention and slowed cleanup operations.
Root Cause
Each connection pool was locked independently, resulting in multiple critical sections and unnecessary synchronization overhead.
Solution
Refactored
drop_poolto acquire all required write locks upfront before performing cleanup.This consolidates cleanup into a single coordinated operation and minimizes lock contention.
Behavior Change
Before
After
Impact
Files Changed
src-tauri/src/db/connection_pool.rsChanges
drop_pool()lock acquisition.Why
src-tauri/src/commands/connections.rsChanges
switch_database()to use consistent error handling.Why
Performance Improvements
The optimized cleanup process reduces synchronization overhead by consolidating lock acquisition into a single critical section.
Results
Impact
Verification
Result<(), VeloxError>Testing Recommendations
Summary
This PR strengthens VeloxDB's connection management by standardizing error handling across all supported database engines and optimizing connection pool cleanup. The result is a more reliable, performant, and maintainable connection management system with improved error reporting, reduced lock contention, and substantially faster cleanup under load—all while maintaining full backward compatibility.