Skip to content

Commit

Permalink
chore: initiate db handle warehouse slave (#3270)
Browse files Browse the repository at this point in the history
  • Loading branch information
cisse21 committed May 4, 2023
1 parent 2c3697a commit bb897b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions warehouse/warehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -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()
Expand Down

0 comments on commit bb897b4

Please sign in to comment.