CritasWang commented on code in PR #62:
URL:
https://github.com/apache/iotdb-client-csharp/pull/62#discussion_r3688063840
##########
src/Apache.IoTDB/SessionPool.cs:
##########
@@ -372,6 +462,16 @@ public async Task<Client> Reconnect(Client originalClient
= null, CancellationTo
throw new ReconnectionFailedException("Error occurs when
reconnecting session pool. Could not connect to any server");
}
+ /// <summary>
+ /// Indicates whether this pool has been opened and not yet closed by
the caller.
+ /// </summary>
+ /// <remarks>
+ /// This reflects the lifecycle of the pool object only - it is NOT a
server-connectivity probe.
+ /// The client performs no heartbeat, so a server going down does not
flip this back to false;
+ /// it stays true until <see cref="Close"/> is called. To reason about
connectivity, use
Review Comment:
Good catch — confirmed and fixed in f855e96. This was a pre-existing defect
that my vacant-slot change made materially worse: previously an empty queue
after an outage just meant "nothing to close", but with capacity retention the
pool could still reconnect after `Close()` returned.
`Close()` now transitions the lifecycle state before touching the queue, and
disarms capacity refill:
```csharp
if (_isClose) return;
_isClose = true;
Volatile.Write(ref _vacantSlots, 0);
foreach (var client in _clients.ClientQueue.AsEnumerable()) { ... }
```
`AcquireClientAsync` additionally checks `!_isClose` before reserving a
slot, so a concurrent operation cannot materialize a connection during or after
teardown.
Regression tests added in `SessionPoolConfigurationTests`:
- `Close_EmptyClientQueue_StillMarksThePoolClosed` — sets up a pool with an
empty queue and eight vacant slots, then asserts `IsOpen()` is false and
`VacantSlots` is zero after `Close()`.
- `Close_IsIdempotentWhenQueueIsEmpty` — a second `Close()` on an empty
queue is a no-op.
Both use reflection to construct the post-outage state, since reaching it
organically requires a live server that then disappears.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]