Skip to content

Commit

Permalink
fix: wrong client returned to the client pool
Browse files Browse the repository at this point in the history
  • Loading branch information
lausannel authored Aug 27, 2024
1 parent 2f8a278 commit d7d412c
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/Apache.IoTDB/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,6 @@ public SessionPool(List<string> nodeUrls, string username, string password, int
public async Task<TResult> ExecuteClientOperationAsync<TResult>(AsyncOperation<TResult> operation, string errMsg, bool retryOnFailure = true)
{
Client client = _clients.Take();
Func<Client, Task<TResult>> executeWithReconnect = async (currentClient) =>
{
try
{
currentClient = await Reconnect(currentClient);
var response = await operation(currentClient);
return response;
}
catch (TException retryEx)
{
throw new TException(errMsg, retryEx);
}
};

try
{
var resp = await operation(client);
Expand All @@ -136,7 +122,13 @@ public async Task<TResult> ExecuteClientOperationAsync<TResult>(AsyncOperation<T
{
if (retryOnFailure)
{
return await executeWithReconnect(client);
try{
client = await Reconnect(client);
return await operation(client);
} catch (TException retryEx)
{
throw new TException(errMsg, retryEx);
}
}
else
{
Expand All @@ -147,7 +139,13 @@ public async Task<TResult> ExecuteClientOperationAsync<TResult>(AsyncOperation<T
{
if (retryOnFailure)
{
return await executeWithReconnect(client);
try{
client = await Reconnect(client);
return await operation(client);
} catch (TException retryEx)
{
throw new TException(errMsg, retryEx);
}
}
else
{
Expand Down

0 comments on commit d7d412c

Please sign in to comment.