[To dev/1.3] Fix SessionPool client leak on reconnection and query failures, and preserve server error messages#45
Open
CritasWang wants to merge 2 commits intodev/1.3from
Open
Conversation
…ilures, and preserve server error messages
There was a problem hiding this comment.
Pull request overview
This pull request fixes critical resource leaks in the SessionPool implementation and enhances error handling by preserving server error messages and adding health monitoring capabilities. The changes address issues where client connections were not properly returned to the pool after reconnection failures or query operation failures.
Changes:
- Fixed client leak when reconnection fails by tracking client lifecycle and preventing closed clients from being returned to the pool
- Fixed client leak when query operations fail by ensuring clients are properly returned unless managed by SessionDataSet
- Enhanced error messages to include original server error details for better debugging
- Added health monitoring metrics (AvailableClients, TotalPoolSize, FailedReconnections) and a new SessionPoolDepletedException for better diagnostics
- Optimized ByteBuffer by replacing LINQ's Reverse().ToArray() with in-place Array.Reverse()
- Fixed IoTDBDataReader.RecordsAffected to return -1 per ADO.NET convention for query results
- Improved thread safety in ConcurrentClientQueue using try-finally for Monitor operations
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| SessionPoolDepletedException.cs | New exception type for pool depletion with diagnostic properties |
| ReconnectionFailedException.cs | Internal exception to distinguish reconnection failures |
| PoolHealthMetrics.cs | Thread-safe metrics tracking for pool health monitoring |
| SessionPool.cs | Core fixes for client lifecycle management, error message preservation, and health metrics integration |
| ConcurrentClientQueue.cs | Improved thread safety and integration with diagnostic reporting |
| SessionDataSet.cs | Added CurrentBatchRowCount() method and deprecated misleading RowCount property |
| IoTDBDataReader.cs | Fixed RecordsAffected to follow ADO.NET conventions |
| ByteBuffer.cs | Performance optimization using Array.Reverse instead of LINQ |
| SessionPool_Exception_Handling.md | Comprehensive documentation for exception handling and monitoring |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [Obsolete("Use CurrentBatchRowCount() instead. This property returns batch size, not total row count.")] | ||
| public int RowCount { get; set; } | ||
|
|
||
| private int _currentBatchRowCount; |
There was a problem hiding this comment.
Field '_currentBatchRowCount' can be 'readonly'.
Suggested change
| private int _currentBatchRowCount; | |
| private readonly int _currentBatchRowCount; |
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.
No description provided.