-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Reproduction:
package main
import (
"context"
"database/sql"
"fmt"
"os"
spannerdriver "github.com/googleapis/go-sql-spanner"
)
func main() {
ctx := context.Background()
db, err := sql.Open("spanner", fmt.Sprintf("projects/%s/instances/%s/databases/%s", os.Getenv("PROJECT"), os.Getenv("INSTANCE"), os.Getenv("DATABASE")))
if err != nil {
panic(err)
}
err = spannerdriver.RunTransaction(ctx, db, &sql.TxOptions{}, func(ctx context.Context, tx *sql.Tx) error {
fmt.Println("Panicking")
panic("panic")
})
if err != nil {
panic(err)
}
fmt.Println("Done")
}
Expected output:
Panicking
panic: panic
followed by the process exiting.
Actual output:
Panicking
followed by the process hanging indefinitely.
Note that adding a call to tx.Rollback() within the function passed to RunTransaction fixes the hang. It seems that the outstanding transaction is causing the deferred call to conn.Close() within runTransactionWithOptions to hang indefinitely.
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.