Skip to content

[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
dev/1.3_fix_session_pool_leak
Open

[To dev/1.3] Fix SessionPool client leak on reconnection and query failures, and preserve server error messages#45
CritasWang wants to merge 2 commits intodev/1.3from
dev/1.3_fix_session_pool_leak

Conversation

@CritasWang
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 6, 2026 06:17
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 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;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Field '_currentBatchRowCount' can be 'readonly'.

Suggested change
private int _currentBatchRowCount;
private readonly int _currentBatchRowCount;

Copilot uses AI. Check for mistakes.
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