ydb-platform / ydb-php-sdk

Apache License 2.0
26 stars 15 forks source link

bug: SDK must retry retriable grpc errors #61

Open gfh31fgh2 opened 1 year ago

gfh31fgh2 commented 1 year ago

Bug Report

YDB PHP SDK version: latest

Environment ubuntu18

Current behavior:

PHP Fatal error:  Uncaught YdbPlatform\Ydb\Exception: YDB Table DeleteSession (status code 14): failed to connect to all addresses; last error: 
UNKNOWN: ipv4:xx.xxx.xxx.xx:2135: tcp handshaker shutdown in /path/vendor/ydb-platform/ydb-php-sdk/src/Traits/RequestTrait.php:163#012
Stack trace:
#012#0 /path/vendor/ydb-platform/ydb-php-sdk/src/Traits/RequestTrait.php(87): YdbPlatform\Ydb\Session->checkStatus('Table', 'DeleteSession', Object(stdClass))
#012#1 /path/vendor/ydb-platform/ydb-php-sdk/src/Session.php(604): YdbPlatform\Ydb\Session->doRequest('Table', 'DeleteSession', Array)
#012#2 /path/vendor/ydb-platform/ydb-php-sdk/src/Session.php(152): YdbPlatform\Ydb\Session->request('DeleteSession', Array)
#012#3 /path/vendor/ydb-platform/ydb-php-sdk/src/Sessions/MemorySessionPool.php(23): YdbPlatform\Ydb\Session->delete()
#012#4 [internal function]: YdbPlatform\Ydb\Sessions\MemorySessionPool->__destruct()
#012#5 {main}#012  thrown in /path/vendor/ydb-platform/ydb-php-sdk/src/Traits/RequestTrait.php on line 163

Expected behavior:

php working more than 12 hours and somehow we lost internet connection

Steps to reproduce:

php in background with simple select from ydb and disconnect of internet on it

Related code:

https://github.com/gfh31fgh2/ydb-php-simple-driver

rekby commented 1 year ago

Hello, thanks for the report.

It is "Unavailable" (code 14) error from grpc library. SDK must retry, but don't do that. https://grpc.github.io/grpc/core/md_doc_statuscodes.html

The exception was in not client code and common retry function will not help there.

We need handle and retry the errors with client code retries and some handle for not client code error handle. Retry or supress them (ok for destructor).

gfh31fgh2 commented 1 year ago

Hello, thanks for the report.

It is "Unavailable" (code 14) error from grpc library. SDK must retry, but don't do that. https://grpc.github.io/grpc/core/md_doc_statuscodes.html

The exception was in not client code and common retry function will not help there.

We need handle and retry the errors with client code retries and some handle for not client code error handle. Retry or supress them (ok for destructor).

так это возмжно сделать? или дело в библиотеке grpc и фикс там нужен?

rekby commented 1 year ago

Да, это возможно - php может ловить grpc-ошибки и может ретраить собственные обращения к серверу.

Со стороны grpc-библиотеки проблемы нет.