Fix SessionPool client leak on reconnection and query failures, and preserve server error messages#44
Open
CritasWang wants to merge 4 commits intomainfrom
Open
Fix SessionPool client leak on reconnection and query failures, and preserve server error messages#44CritasWang wants to merge 4 commits intomainfrom
CritasWang wants to merge 4 commits intomainfrom
Conversation
…reserve server error messages - Add SessionPoolDepletedException with diagnostic properties for pool depletion scenarios - Add ReconnectionFailedException for type-safe reconnection failure detection - Fix client leak when reconnection succeeds but retry operation fails - Add PoolHealthMetrics for thread-safe health monitoring - Add try-finally protection for Monitor locks in ConcurrentClientQueue - Remove silent failure pattern - always log connection failures - Add CurrentBatchRowCount() method with Obsolete attribute on RowCount() - Improve database switch error handling with partial failure detection
There was a problem hiding this comment.
Pull request overview
This pull request addresses a critical client leak issue in the SessionPool when reconnection succeeds but the retry operation fails. It also introduces comprehensive exception handling, health monitoring capabilities, and improves error reporting.
Changes:
- Introduced SessionPoolDepletedException and ReconnectionFailedException for type-safe error handling
- Fixed client leak by properly managing client return to pool in all execution paths
- Added PoolHealthMetrics for thread-safe monitoring of pool health
- Improved connection failure logging and removed silent failure pattern
- Added database switch partial failure detection
- Deprecated RowCount() in favor of CurrentBatchRowCount() for clarity
- Fixed RecordsAffected to follow ADO.NET conventions (-1 for queries)
- Added comprehensive documentation for exception handling and monitoring
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| SessionPoolDepletedException.cs | New exception class with diagnostic properties for pool depletion scenarios |
| ReconnectionFailedException.cs | Internal exception for type-safe reconnection failure detection |
| PoolHealthMetrics.cs | Thread-safe health metrics tracking for reconnection failures and pool size |
| SessionPool.cs | Fixed client leak in ExecuteClientOperationAsync, improved error messages, added health monitoring, enhanced database switch error handling |
| ConcurrentClientQueue.cs | Added try-finally protection for Monitor locks in Take(), refactored ref counting to use Interlocked operations, integrated diagnostic reporter |
| SessionDataSet.cs | Added CurrentBatchRowCount() method and deprecated RowCount() with clear guidance |
| IoTDBDataReader.cs | Updated to use CurrentBatchRowCount() and set RecordsAffected to -1 per ADO.NET convention |
| SessionPool_Exception_Handling.md | Comprehensive documentation on exception handling, health monitoring, and recovery strategies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* switch to dotnet format * format
HTHou
approved these changes
Feb 6, 2026
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.
link apache/iotdb#17163