Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when using timestream QueryWithContext with X-Ray #411

Open
sportlane opened this issue Mar 30, 2023 · 0 comments
Open

panic when using timestream QueryWithContext with X-Ray #411

sportlane opened this issue Mar 30, 2023 · 0 comments

Comments

@sportlane
Copy link

sportlane commented Mar 30, 2023

Describe the bug

When using timestreamquery QueryWithContext function with X-Ray, the program panic with the error:
"panic: failed to begin subsegment named 'Timestream Query': segment cannot be found."

The DescribeEndpoints call queued before QueryWithContext is not getting context set up.

Current Behavior

panic: failed to begin subsegment named 'Timestream Query': segment cannot be found.

goroutine 1 [running]:
github.com/aws/aws-xray-sdk-go/strategy/ctxmissing.(*DefaultRuntimeErrorStrategy).ContextMissing(0xc0000302d0?, {0x17376e0?, 0xc00062cd70?})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/strategy/ctxmissing/default_context_missing.go:60 +0x29
github.com/aws/aws-xray-sdk-go/xray.BeginSubsegment({0x1ae9510, 0xc000028068}, {0x18433c3, 0x10})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/xray/segment.go:272 +0x6a8
github.com/aws/aws-xray-sdk-go/xray.glob..func1(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/xray/aws.go:67 +0x75
github.com/aws/aws-sdk-go/aws/request.(*HandlerList).Run(0xc0003686a8, 0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/handlers.go:267 +0x9a
github.com/aws/aws-sdk-go/aws/request.(*Request).Build(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:416 +0x39
github.com/aws/aws-sdk-go/aws/request.(*Request).Sign(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:437 +0x25
github.com/aws/aws-sdk-go/aws/request.(*Request).Send(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:550 +0x13b
github.com/aws/aws-sdk-go/service/timestreamquery.(*TimestreamQuery).DescribeEndpoints(0x18394a4?, 0x4?)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:465 +0x25
github.com/aws/aws-sdk-go/service/timestreamquery.(*discovererDescribeEndpoints).Discover(0xc000638340)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:496 +0x5e
github.com/aws/aws-sdk-go/aws/crr.(*EndpointCache).discover(0xc000513908?, {0x1ae3ac0?, 0xc000638340?}, {0x1839e2f, 0x5})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/crr/cache.go:113 +0x66
github.com/aws/aws-sdk-go/aws/crr.(*EndpointCache).Get(0xc000638000, {0x1ae3ac0?, 0xc000638340}, {0x1839e2f, 0x5}, 0x1)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/crr/cache.go:64 +0x11b
github.com/aws/aws-sdk-go/service/timestreamquery.(*discovererDescribeEndpoints).Handler(0xc000638340, 0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:545 +0x86
github.com/aws/aws-sdk-go/aws/request.(*HandlerList).Run(0xc0003681c8, 0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/handlers.go:267 +0x9a
github.com/aws/aws-sdk-go/aws/request.(*Request).Build(0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:421 +0x67
github.com/aws/aws-sdk-go/aws/request.(*Request).Sign(0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:437 +0x25
github.com/aws/aws-sdk-go/aws/request.(*Request).Send(0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:550 +0x13b
github.com/aws/aws-sdk-go/service/timestreamquery.(*TimestreamQuery).QueryWithContext(0x1ae9510?, {0x1ae9580, 0xc0006139e0}, 0x4?, {0x0, 0x0, 0xc00034b0e0?})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:1396 +0x186
main.main()
        /Users/user/Documents/Source/test/ts-test.go:25 +0x185
exit status 2

Reproduction Steps

package main

import (
	"context"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/timestreamquery"
	"github.com/aws/aws-xray-sdk-go/xray"
)

func main() {

	sess := session.Must(session.NewSessionWithOptions(session.Options{
		SharedConfigState: session.SharedConfigEnable,
		Config: aws.Config{
			Region: aws.String("us-east-1"),
		},
	}))

	tsclient := timestreamquery.New(sess)
	xray.AWS(tsclient.Client)

	ctx, _ := xray.BeginSegment(context.Background(), "test")
	tsclient.QueryWithContext(ctx, &timestreamquery.QueryInput{
		QueryString: aws.String("SELECT * FROM FOO"),
	})
}

SDK version used

v1.7.0

Environment details (Version of Go (go version)? OS name and version, etc.)

go version go1.19.3 darwin/amd64

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

No branches or pull requests

1 participant