Skip to content

Fix SessionPool client leak on reconnection and query failures, and preserve server error messages#44

Open
CritasWang wants to merge 4 commits intomainfrom
fix_session_pool_leak
Open

Fix SessionPool client leak on reconnection and query failures, and preserve server error messages#44
CritasWang wants to merge 4 commits intomainfrom
fix_session_pool_leak

Conversation

@CritasWang
Copy link
Contributor

  • 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

link apache/iotdb#17163

…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
Copilot AI review requested due to automatic review settings February 6, 2026 05:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

CritasWang and others added 3 commits February 6, 2026 14:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* switch to dotnet format

* format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants