Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

When ydb.Open is called with an already-expired context, the error message chains multiple stack traces, making it difficult to diagnose:

retry failed on attempt No.1: context deadline exceeded at `retry.RetryWithResult(retry.go:337)` at `retry.Retry(retry.go:270)` at `balancer.New(balancer.go:322)` at `(*Driver).connect(driver.go:458)` at `Open(driver.go:314)`

Changes

  • retry/retry.go: Check for expired context before entering retry loop; avoid wrapping context errors with stack traces
  • internal/balancer/balancer.go: Propagate context errors without stack trace wrapping
  • driver.go: Propagate context errors without stack trace wrapping

Context errors now show a single, meaningful stack trace at the Open() level:

context deadline exceeded at `github.com/ydb-platform/ydb-go-sdk/v3.Open(driver.go:314)`

The early context check in retry logic also prevents misleading "retry failed on attempt No.1" messages when no actual retry attempt was made.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid_host

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>bug: Unreadable error when context deadline is exceeded in ydb.Open</issue_title>
<issue_description># Bug Report

YDB GO SDK version:

v3.118.0

Environment

All environments

Current behavior:

When the context passed to ydb.Open has its deadline exceeded, an error message is displayed that is difficult to understand. This makes it challenging to diagnose and resolve the issue.

Expected behavior:

Error something like: context deadline exceeded at Open(driver.go:XXX)

Steps to reproduce:

  1. Create a context with a deadline that has already been exceeded.
  2. Pass this context to the ydb.Open function.
  3. Observe the error message that is returned.
func TestOpen(t *testing.T) {
	ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
	defer cancel()

	time.Sleep(10 * time.Nanosecond)

	_, err := ydb.Open(ctx, "grpc://localhost:2136/local")
	require.NoError(t, err)
}
Error:          Received unexpected error:
                                retry failed on attempt No.1: context deadline exceeded at `github.com/ydb-platform/ydb-go-sdk/v3/retry.RetryWithResult(retry.go:337)` at `github.com/ydb-platform/ydb-go-sdk/v3/retry.Retry(retry.go:270)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer.New(balancer.go:322)` at `github.com/ydb-platform/ydb-go-sdk/v3.(*Driver).connect(driver.go:458)` at `github.com/ydb-platform/ydb-go-sdk/v3.Open(driver.go:314)`
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix unreadable error when context deadline is exceeded Fix unreadable context error in ydb.Open Nov 1, 2025
Copilot AI requested a review from asmyasnikov November 1, 2025 13:45
Copilot finished work on behalf of asmyasnikov November 1, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Unreadable error when context deadline is exceeded in ydb.Open

2 participants