Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(OOM): close ticker to prevent resource leaks (#1657)

h3n4lfb4cc46ab227
diff --git a/server/task_executor_schema_update_ghost_cutover.go b/server/task_executor_schema_update_ghost_cutover.go
index 066d859dcb..65a807cc4e 100644
--- a/server/task_executor_schema_update_ghost_cutover.go
+++ b/server/task_executor_schema_update_ghost_cutover.go
@@ -49,6 +49,7 @@ func (exec *SchemaUpdateGhostCutoverTaskExecutor) RunOnce(ctx context.Context, s
}
ticker := time.NewTicker(time.Second * 1)
+ defer ticker.Stop()
for range ticker.C {
if _, err := os.Stat(socketFilename); err != nil {
diff --git a/server/task_executor_schema_update_ghost_sync.go b/server/task_executor_schema_update_ghost_sync.go
index 1da597b626..948c992188 100644
--- a/server/task_executor_schema_update_ghost_sync.go
+++ b/server/task_executor_schema_update_ghost_sync.go
@@ -271,6 +271,7 @@ func executeGhost(task *api.Task, startedNs int64, statement string, syncDone ch
go func(ctx context.Context, migrationContext *base.MigrationContext) {
ticker := time.NewTicker(1 * time.Second)
+ defer ticker.Stop()
for {
select {
case <-ticker.C:
diff --git a/store/pg_engine_test.go b/store/pg_engine_test.go
index 02eefc358c..4b38866a93 100644
--- a/store/pg_engine_test.go
+++ b/store/pg_engine_test.go
@@ -166,6 +166,7 @@ func TestMigrationCompatibility(t *testing.T) {
dbdriver.ConnectionContext{},
)
require.NoError(t, err)
+ defer d.Close(ctx)
err = d.SetupMigrationIfNeeded(ctx)
require.NoError(t, err)
diff --git a/tests/backup_restore_test.go b/tests/backup_restore_test.go
index 1166641829..cc0aff3a4e 100644
--- a/tests/backup_restore_test.go
+++ b/tests/backup_restore_test.go
@@ -451,6 +451,7 @@ func startUpdateRow(ctx context.Context, t *testing.T, database string, port int
go func() {
defer db.Close()
ticker := time.NewTicker(1 * time.Millisecond)
+ defer ticker.Stop()
i := 0
for {
select {