-
Notifications
You must be signed in to change notification settings - Fork 406
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
Spanner DBX pool is unreliable #7117
Labels
Bug
Something isn't working
Comments
Looks like this is the moment when the SQL session is closed:
|
Code to reproduce it: // Copyright 2021 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"context"
"database/sql"
"fmt"
_ "github.com/googleapis/go-sql-spanner"
"time"
)
// Simple sample application that shows how to use the Spanner Go sql driver.
//
// Execute the sample with the command `go run main.go` from this directory.
func helloWorld() error {
ctx := context.Background()
db, err := sql.Open("spanner", "projects/storj-test/instances/test-instance/databases/satellite")
if err != nil {
return fmt.Errorf("failed to open database connection: %v\n", err)
}
defer db.Close()
db.SetConnMaxLifetime(time.Second * 20)
for i := 0; i < 10000; i++ {
err := selectOnce(ctx, db)
if err != nil {
return err
}
time.Sleep(1 * time.Second)
}
return nil
}
func selectOnce(ctx context.Context, db *sql.DB) error {
rows, err := db.QueryContext(ctx, "SELECT 'Hello World!'")
if err != nil {
return fmt.Errorf("failed to execute query: %v", err)
}
defer rows.Close()
var msg string
for rows.Next() {
if err := rows.Scan(&msg); err != nil {
return fmt.Errorf("failed to scan row values: %v", err)
}
fmt.Printf("%s\n", msg)
}
if err := rows.Err(); err != nil {
return fmt.Errorf("failed to execute query: %v", err)
}
return nil
}
func main() {
err := helloWorld()
if err != nil {
panic(err)
}
} |
Upstream issue googleapis/go-sql-spanner#288 and fix googleapis/go-sql-spanner#290 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Satellite API can be started with using Spanner, and during the first few minutes, everything works well.
But after a while, all database queries start failing, with an error related to spanner session pool:
The text was updated successfully, but these errors were encountered: