satellite/metabase/metaloop: add as of system interval to stats

Table stats query should use AS OF SYSTEM INTERVAL in the query to optimize
the behavior.

Change-Id: Ie14f5441062d3d264bb3c626081e77d6edc7b724
This commit is contained in:
Egon Elbre 2021-06-17 19:49:40 +03:00
parent 9640cc2c06
commit 5f901c8066
2 changed files with 14 additions and 6 deletions

View File

@ -164,7 +164,7 @@ type Config struct {
RateLimit float64 `help:"rate limit (default is 0 which is unlimited segments per second)" default:"0"`
ListLimit int `help:"how many items to query in a batch" default:"2500" testDefault:"10000"`
AsOfSystemInterval time.Duration `help:"as of system interval" default:"-5m"`
AsOfSystemInterval time.Duration `help:"as of system interval" releaseDefault:"-5m" devDefault:"-1us" testDefault:"-1us"`
SuspiciousProcessedRatio float64 `help:"ratio where to consider processed count as supicious" default:"0.03"`
}
@ -368,7 +368,9 @@ func (loop *Service) iterateDatabase(ctx context.Context, observers []*observerC
finishObservers(observers)
}()
before, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{})
before, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{
AsOfSystemInterval: loop.config.AsOfSystemInterval,
})
if err != nil {
return Error.Wrap(err)
}
@ -382,7 +384,9 @@ func (loop *Service) iterateDatabase(ctx context.Context, observers []*observerC
return Error.Wrap(err)
}
after, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{})
after, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{
AsOfSystemInterval: loop.config.AsOfSystemInterval,
})
if err != nil {
return Error.Wrap(err)
}

View File

@ -140,7 +140,7 @@ type Config struct {
RateLimit float64 `help:"rate limit (default is 0 which is unlimited segments per second)" default:"0"`
ListLimit int `help:"how many items to query in a batch" default:"2500"`
AsOfSystemInterval time.Duration `help:"as of system interval" default:"-5m"`
AsOfSystemInterval time.Duration `help:"as of system interval" releaseDefault:"-5m" devDefault:"-1us" testDefault:"-1us"`
SuspiciousProcessedRatio float64 `help:"ratio where to consider processed count as supicious" default:"0.03"`
}
@ -339,7 +339,9 @@ func (loop *Service) iterateDatabase(ctx context.Context, observers []*observerC
finishObservers(observers)
}()
before, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{})
before, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{
AsOfSystemInterval: loop.config.AsOfSystemInterval,
})
if err != nil {
return Error.Wrap(err)
}
@ -353,7 +355,9 @@ func (loop *Service) iterateDatabase(ctx context.Context, observers []*observerC
return Error.Wrap(err)
}
after, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{})
after, err := loop.metabaseDB.GetTableStats(ctx, metabase.GetTableStats{
AsOfSystemInterval: loop.config.AsOfSystemInterval,
})
if err != nil {
return Error.Wrap(err)
}