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

fix(spanner): spanner sessions will be cleaned up from the backend #6679

Merged
merged 4 commits into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions spanner/client.go
Expand Up @@ -359,11 +359,6 @@ func (c *Client) BatchReadOnlyTransaction(ctx context.Context, tb TimestampBound
sh *sessionHandle
err error
)
defer func() {
if err != nil && sh != nil {
s.delete(ctx)
}
}()

// Create session.
s, err = c.sc.createSession(ctx)
Expand Down
5 changes: 3 additions & 2 deletions spanner/client_test.go
Expand Up @@ -3250,7 +3250,8 @@ func TestClient_CloseWithUnresponsiveBackend(t *testing.T) {
defer cancel()
sp.close(ctx)

if w, g := context.DeadlineExceeded, ctx.Err(); w != g {
t.Fatalf("context error mismatch\nWant: %v\nGot: %v", w, g)
// session pool close does not trigger any request to backend
if ctx.Err() != nil {
t.Fatalf("context error mismatch\nWant: nil\nGot: %v", ctx.Err())
}
}
2 changes: 0 additions & 2 deletions spanner/session.go
Expand Up @@ -343,8 +343,6 @@ func (s *session) destroyWithContext(ctx context.Context, isExpire bool) bool {
}
// Unregister s from healthcheck queue.
s.pool.hc.unregister(s)
// Remove s from Cloud Spanner service.
s.delete(ctx)
return true
}

Expand Down
8 changes: 0 additions & 8 deletions spanner/session_test.go
Expand Up @@ -417,10 +417,6 @@ func TestTakeFromIdleListChecked(t *testing.T) {
if err != nil {
t.Fatalf("failed to get session: %v", err)
}
ds := server.TestSpanner.DumpSessions()
if g, w := uint64(len(ds)), sp.incStep-1; g != w {
t.Fatalf("number of sessions from mock server mismatch\nGot: %v\nWant: %v\n", g, w)
}
if sh.getID() == wantSid {
t.Fatalf("sessionPool.Take still returns the same session %v, want it to create a new one", wantSid)
}
Expand Down Expand Up @@ -494,10 +490,6 @@ func TestTakeFromIdleWriteListChecked(t *testing.T) {
if err != nil {
t.Fatalf("failed to get session: %v", err)
}
ds := server.TestSpanner.DumpSessions()
if g, w := uint64(len(ds)), sp.incStep-1; g != w {
t.Fatalf("number of sessions from mock server mismatch\nGot: %v\nWant: %v\n", g, w)
}
if sh.getID() == wantSid {
t.Fatalf("sessionPool.Take still returns the same session %v, want it to create a new one", wantSid)
}
Expand Down