Skip to content

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

fix: db close (#15965)

p0ny9aa7c8b78322
diff --git a/action/main.go b/action/main.go
index a163829100..a85ad58ca2 100644
--- a/action/main.go
+++ b/action/main.go
@@ -1,11 +1,13 @@
package main
import (
+ "log/slog"
"os"
"github.com/spf13/cobra"
"github.com/bytebase/bytebase/action/github"
+ "github.com/bytebase/bytebase/backend/common/log"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
@@ -92,5 +94,8 @@ func runCI(*cobra.Command, []string) error {
}
func main() {
- cmd.Execute()
+ if err := cmd.Execute(); err != nil {
+ slog.Error("failed to execute command", log.BBError(err))
+ os.Exit(1)
+ }
}
diff --git a/backend/demo/demo.go b/backend/demo/demo.go
index 12584a0a6d..8ca9d84caa 100644
--- a/backend/demo/demo.go
+++ b/backend/demo/demo.go
@@ -19,6 +19,7 @@ func LoadDemoData(ctx context.Context, pgURL string) error {
if err != nil {
return err
}
+ defer db.Close()
// This query in the dump.sql will poison the connection.
// SELECT pg_catalog.set_config('search_path', '', false);
var ok bool
diff --git a/backend/migrator/migrator.go b/backend/migrator/migrator.go
index f485ddbc9e..5ff2e6d991 100644
--- a/backend/migrator/migrator.go
+++ b/backend/migrator/migrator.go
@@ -32,6 +32,7 @@ func MigrateSchema(ctx context.Context, pgURL string) error {
if err != nil {
return err
}
+ defer db.Close()
conn, err := db.Conn(ctx)
if err != nil {
return err