Skip to content

[do not merge] initialize pool from scratch after TableGC.Close #164

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

Closed
wants to merge 11 commits into from

Conversation

mhamza15
Copy link

No description provided.

@mhamza15 mhamza15 self-assigned this May 27, 2025
@Copilot Copilot AI review requested due to automatic review settings May 27, 2025 19:23
@mhamza15 mhamza15 changed the title initialize pool from scratch after TableGC.Close [do not merge] initialize pool from scratch after TableGC.Close May 27, 2025
@mhamza15 mhamza15 closed this May 27, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR centralizes connection pool creation for TableGC, ensures pools are reinitialized after Close, and adds tests and safeguards for reopening pools and expvar registration.

  • Extract pool creation into newPool helper and use it in constructor, Open, and Close
  • Reinitialize collector.pool if it’s nil in Open
  • Add tests for reopening pools and ignore duplicate expvar registrations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
go/vt/vttablet/tabletserver/gc/tablegc.go Moved inline pool config into newPool, added reinit in Open, and clear in Close
go/vt/vttablet/tabletserver/connpool/pool_test.go Added TestReopenPool & TestReopenPoolUnnamedEnv to verify reopening behavior
go/stats/export.go Guard against duplicate expvar.Publish by checking expvar.Get
Comments suppressed due to low confidence (2)

go/vt/vttablet/tabletserver/gc/tablegc.go:717

  • [nitpick] The helper newPool name is very generic and may collide with other packages or cause confusion. Consider renaming it to newTableGCPool to clarify its purpose.
func newPool(env tabletenv.Env) *connpool.Pool {

go/stats/export.go:104

  • There’s no test covering the case where a duplicate expvar is ignored. Adding a unit test for this guard would ensure the intended behavior is verified.
if v := expvar.Get(name); v != nil {


func newPool(env tabletenv.Env) *connpool.Pool {
return connpool.NewPool(env, "TableGCPool", tabletenv.ConnPoolConfig{
Size: 2,
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The pool size 2 is hard-coded here. Extract this into a named constant or configuration so its meaning is clear and easier to adjust.

Suggested change
Size: 2,
Size: DefaultTableGCPoolSize,

Copilot uses AI. Check for mistakes.

@@ -50,6 +50,72 @@ func TestConnPoolGet(t *testing.T) {
dbConn.Recycle()
}

func TestReopenPool(t *testing.T) {
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The two tests TestReopenPool and TestReopenPoolUnnamedEnv share almost identical logic. Consider consolidating them into a table-driven test to reduce duplication.

Copilot uses AI. Check for mistakes.

@@ -100,6 +100,11 @@ func (vg *varGroup) publish(name string, v expvar.Var) {
vg.Lock()
defer vg.Unlock()

// Ignore if the variable is already registered
if v := expvar.Get(name); v != nil {
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inner variable v shadows the parameter v, which can be confusing. Rename the shadowed variable (e.g., existing) to improve readability.

Suggested change
if v := expvar.Get(name); v != nil {
if existing := expvar.Get(name); existing != nil {

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

1 participant