Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/consistency/diff/repset_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pgedge/ace/db/queries"
"github.com/pgedge/ace/internal/infra/db"
utils "github.com/pgedge/ace/pkg/common"
"github.com/pgedge/ace/pkg/config"
"github.com/pgedge/ace/pkg/logger"
"github.com/pgedge/ace/pkg/taskstore"
"github.com/pgedge/ace/pkg/types"
Expand Down Expand Up @@ -88,7 +89,7 @@ func NewRepsetDiffTask() *RepsetDiffCmd {
}

func (c *RepsetDiffCmd) connOpts() auth.ConnectionOptions {
return auth.ConnectionOptions{}
return auth.ConnectionOptions{PoolSize: c.MaxConnections}
}

func (c *RepsetDiffCmd) parseSkipList() error {
Expand Down Expand Up @@ -231,6 +232,10 @@ func (c *RepsetDiffCmd) Validate() error {
if c.RepsetName == "" {
return fmt.Errorf("repset name is required")
}
cfg := config.Get()
if c.MaxConnections == 0 && cfg != nil {
c.MaxConnections = cfg.TableDiff.MaxConnections
}
if c.MaxConnections < 0 {
return fmt.Errorf("max_connections must be >= 1 (or 0 to derive from concurrency factor)")
}
Expand Down
9 changes: 7 additions & 2 deletions internal/consistency/diff/schema_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/pgedge/ace/db/queries"
"github.com/pgedge/ace/internal/infra/db"
utils "github.com/pgedge/ace/pkg/common"
"github.com/pgedge/ace/pkg/config"
"github.com/pgedge/ace/pkg/logger"
"github.com/pgedge/ace/pkg/taskstore"
"github.com/pgedge/ace/pkg/types"
Expand Down Expand Up @@ -178,6 +179,10 @@ func (c *SchemaDiffCmd) Validate() error {
return fmt.Errorf("schema-diff needs at least two nodes to compare")
}

cfg := config.Get()
if c.MaxConnections == 0 && cfg != nil {
c.MaxConnections = cfg.TableDiff.MaxConnections
}
if c.MaxConnections < 0 {
return fmt.Errorf("max_connections must be >= 1 (or 0 to derive from concurrency factor)")
}
Expand Down Expand Up @@ -220,7 +225,7 @@ func (c *SchemaDiffCmd) RunChecks(skipValidation bool) error {
}
}

pool, err := auth.GetClusterNodeConnection(c.Ctx, nodeWithDBInfo, auth.ConnectionOptions{})
pool, err := auth.GetClusterNodeConnection(c.Ctx, nodeWithDBInfo, auth.ConnectionOptions{PoolSize: c.MaxConnections})
if err != nil {
return fmt.Errorf("could not connect to node %s: %w", nodeName, err)
}
Expand Down Expand Up @@ -300,7 +305,7 @@ func (task *SchemaDiffCmd) schemaObjectDiff() error {
}
}

pool, err := auth.GetClusterNodeConnection(task.Ctx, nodeWithDBInfo, auth.ConnectionOptions{})
pool, err := auth.GetClusterNodeConnection(task.Ctx, nodeWithDBInfo, auth.ConnectionOptions{PoolSize: task.MaxConnections})
if err != nil {
logger.Warn("could not connect to node %s: %v. Skipping.", nodeName, err)
continue
Expand Down
12 changes: 10 additions & 2 deletions internal/jobs/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@ func (m *Manager) Run(ctx context.Context) error {

switch {
case job.Cron != "":
gJob, err = m.scheduler.NewJob(gocron.CronJob(job.Cron, false), gocron.NewTask(runFn))
gJob, err = m.scheduler.NewJob(
gocron.CronJob(job.Cron, false),
gocron.NewTask(runFn),
gocron.WithSingletonMode(gocron.LimitModeReschedule),
)
case job.Frequency > 0:
gJob, err = m.scheduler.NewJob(gocron.DurationJob(job.Frequency), gocron.NewTask(runFn))
gJob, err = m.scheduler.NewJob(
gocron.DurationJob(job.Frequency),
gocron.NewTask(runFn),
gocron.WithSingletonMode(gocron.LimitModeReschedule),
)
default:
return fmt.Errorf("scheduler: job %q requires either frequency or cron", job.Name)
}
Expand Down
Loading