Skip to content

Commit d4ee6b9

Browse files
committed
Fixed bug, when function Retry::backoffType always return SlowBackoff
1 parent 6fc8d9a commit d4ee6b9

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
* fixed bug, when function Retry::backoffType always return SlowBackoff
2+
13
# 1.8.0
4+
25
* update destructor in MemorySessionPool
36
* fixed exception on re-create server nodes
47
* fixed key name in createTable function

src/Retry/Retry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function retry(Closure $closure, bool $idempotent)
7878
$retryCount = 0;
7979
$lastException = null;
8080
while (microtime(true) < $startTime + $this->timeoutMs / 1000) {
81-
$this->logger->debug("YDB: Run user function. Retry count: $retryCount. Ms: ".(microtime(true) - $startTime));
81+
$this->logger->debug("YDB: Run user function. Retry count: $retryCount. s: ".(microtime(true) - $startTime));
8282
try {
8383
return $closure();
8484
} catch (Exception $e) {
@@ -89,7 +89,7 @@ public function retry(Closure $closure, bool $idempotent)
8989
}
9090
$retryCount++;
9191
$lastException = $e;
92-
$delay = $this->retryDelay($retryCount, $this->backoffType($e))*1000;
92+
$delay = $this->retryDelay($retryCount, $this->backoffType(get_class($e)))*1000;
9393
usleep($delay);
9494
}
9595
}

tests/RetryOnExceptionTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use YdbPlatform\Ydb\Session;
99
use YdbPlatform\Ydb\Table;
1010
use YdbPlatform\Ydb\Ydb;
11+
use YdbPlatform\Ydb\Logger\SimpleFileLogger;
1112

1213
class SessionManager extends \YdbPlatform\Ydb\Session{
1314
public static function setSessionId(\YdbPlatform\Ydb\Session $session, string $id){
@@ -46,7 +47,8 @@ public function test(){
4647
'credentials' => new AnonymousAuthentication()
4748
];
4849

49-
$ydb = new Ydb($config);
50+
$ydb = new Ydb($config, new SimpleFileLogger(7, "l.log"));
51+
// $ydb = new Ydb($config);
5052
$table = $ydb->table();
5153

5254
$session = $table->createSession();
@@ -69,6 +71,6 @@ private function retryTest(Table $table)
6971
1,
7072
$tres
7173
);
72-
}, true, new RetryParams(20000));
74+
}, true, new RetryParams(2000));
7375
}
7476
}

0 commit comments

Comments
 (0)