Skip to content

spanner: Error wraped into Internal #7740

@osterante

Description

@osterante

Client

Spanner v1.45.0

Environment

The local environment on M1 MacBookPro

Go Environment
$ go version
go version go1.20 darwin/arm64

$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/UserName/Library/Caches/go-build"
GOENV="/Users/UserName/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/UserName/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/UserName/go"
GOPROXY="https://proxy.golang.org/,direct"
GOROOT="/Users/UserName/.anyenv/envs/goenv/versions/1.20.0"
GOSUMDB="[sum.golang.org](http://sum.golang.org/)"
GOTMPDIR=""
GOTOOLDIR="/Users/UserName/.anyenv/envs/goenv/versions/1.20.0/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/UserName/Projects/Project/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x3/0yyktc4d5_11gvj8gsjxsck5mc3vtb/T/go-build887811120=/tmp/go-build -gno-record-gcc-switches -fno-common"

Code

e.g.

func main() {
        ctx, cancel := context.WithCancel(context.Background())
        client, _ := spanner.NewClient(ctx, "path to db")

        _, err = client.ReadWriteTransaction(ctx, func(ctx context.Context, tx *spanner.ReadWriteTransaction) error {
                iter := tx.Query(ctx, spanner.NewStatement("SELECT 1"))
                if _, err := iter.Next(); err != nil {
                        return err
                }
                return nil
        })
        if err != nil {
                panic(err)
        }

        cancel() // cancel here

        _, err = client.ReadWriteTransaction(ctx, func(ctx context.Context, tx *spanner.ReadWriteTransaction) error {
                iter := tx.Query(ctx, spanner.NewStatement("SELECT 1"))
                if _, err := iter.Next(); err != nil {
                        return err
                }
                return nil
        })
        if err != nil {
                if status.Code(err) == codes.Canceled {
                        fmt.Println("expected")
                } else {
                        fmt.Printf("Unexpected err: %v", err)
                }
        }
}

Expected behavior

print expected

Actual behavior

Unexpected err: spanner: code = "Internal", desc = "error while BeginTransaction during retrying a ReadWrite transaction: spanner: code = \"Canceled\", desc = \"context canceled\""

Additional context

It happens after #7149 is merged.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions