Skip to content

Commit 1264518

Browse files
XmasApplerekby
authored andcommitted
Add retry to GetSession in SessionPool.cs
1 parent 5679889 commit 1264518

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Ydb.Sdk/src/Services/Table/SessionPool.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ public SessionPool(Driver driver, SessionPoolConfig config)
9191
}
9292

9393
public async Task<GetSessionResponse> GetSession()
94+
{
95+
const int maxAttempts = 100;
96+
97+
GetSessionResponse getSessionResponse = null!;
98+
for (var attempt = 0; attempt < maxAttempts; attempt++)
99+
{
100+
getSessionResponse = await GetSessionAttempt();
101+
}
102+
103+
_logger.LogError($"Failed to get session from pool or create it (attempts: {maxAttempts})");
104+
return getSessionResponse;
105+
}
106+
107+
private async Task<GetSessionResponse> GetSessionAttempt()
94108
{
95109
lock (_lock)
96110
{

0 commit comments

Comments
 (0)