From bb897b4cb8857db0d885865775e497e30cc78ef4 Mon Sep 17 00:00:00 2001 From: Rohith BCS Date: Thu, 4 May 2023 13:21:39 +0530 Subject: [PATCH] chore: initiate db handle warehouse slave (#3270) --- warehouse/warehouse.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/warehouse/warehouse.go b/warehouse/warehouse.go index 34547caf2d..57772c9510 100644 --- a/warehouse/warehouse.go +++ b/warehouse/warehouse.go @@ -1587,10 +1587,6 @@ func isStandAloneSlave() bool { } func setupDB(ctx context.Context, connInfo string) error { - if isStandAloneSlave() { - return nil - } - var err error dbHandle, err = sql.Open("postgres", connInfo) if err != nil { @@ -1608,6 +1604,10 @@ func setupDB(ctx context.Context, connInfo string) error { return err } + if isStandAloneSlave() { + dbHandle.SetMaxOpenConns(1) + } + if err = dbHandle.PingContext(ctx); err != nil { return fmt.Errorf("could not ping WH db: %w", err) } @@ -1617,7 +1617,7 @@ func setupDB(ctx context.Context, connInfo string) error { // Setup prepares the database connection for warehouse service, verifies database compatibility and creates the required tables func Setup(ctx context.Context) error { - if !isStandAlone() && !db.IsNormalMode() { + if !db.IsNormalMode() { return nil } psqlInfo := getConnectionString()