Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #1578

Closed
wants to merge 1 commit into from
Closed

Revert #1578

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
9 changes: 5 additions & 4 deletions internal/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const (
cacheInvalidateCheckInterval = 1 * time.Second
cacheInvalidateCheckTimeout = 5 * time.Second
cacheInvalidateMaxRows = 100_000
cacheDefaultDropEvery = 90 * time.Second

queryClientCache = 1 * time.Second
queryClientCacheStale = 9 * time.Second // ~ v2 lag
Expand Down Expand Up @@ -629,7 +630,7 @@ func NewHandler(staticDir fs.FS, jsSettings JSSettings, showInvisible bool, chV1
bufferPoolBytesFree: statshouse.GetMetricRef(format.BuiltinMetricAPIBufferBytesFree, statshouse.Tags{1: srvfunc.HostnameForStatshouse(), 2: "1"}),
bufferPoolBytesTotal: statshouse.GetMetricRef(format.BuiltinMetricAPIBufferBytesTotal, statshouse.Tags{1: srvfunc.HostnameForStatshouse()}),
}
h.cache = newTSCacheGroup(cfg.ApproxCacheMaxSize, data_model.LODTables, h.utcOffset, loadPoints)
h.cache = newTSCacheGroup(cfg.ApproxCacheMaxSize, data_model.LODTables, h.utcOffset, loadPoints, cacheDefaultDropEvery)
h.pointsCache = newPointsCache(cfg.ApproxCacheMaxSize, h.utcOffset, loadPoint, time.Now)
cl.AddChangeCB(func(c config.Config) {
cfg := c.(*Config)
Expand Down Expand Up @@ -786,7 +787,7 @@ SETTINGS
IsLight: true,
User: "cache-update",
Metric: format.BuiltinMetricIDContributorsLog,
Table: _1sTableSH3,
Table: _1sTableSH2,
Kind: "cache-update",
}, Version2, ch.Query{
Body: queryBody,
Expand All @@ -805,7 +806,7 @@ SETTINGS
if _, ok := seen[r]; ok {
continue
}
for lodLevel := range data_model.LODTables[Version3] {
for lodLevel := range data_model.LODTables[Version2] {
t := roundTime(r.At, lodLevel, h.utcOffset)
w := todo[lodLevel]
if len(w) == 0 || w[len(w)-1] != t {
Expand Down Expand Up @@ -869,7 +870,7 @@ func (r *requestHandler) version() string {
if r.versionDice != nil {
return r.versionDice()
}
return Version3
return Version2
}

func (h *Handler) getMetricNameWithNamespace(metricID int32) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (pq *pointsQuery) cacheKey() string {
case Version1:
sb.WriteString(Version1)
default:
sb.WriteString(Version3)
sb.WriteString(Version2)
}
sb.WriteString(";m=")
sb.WriteString(fmt.Sprint(pq.metricID))
Expand Down
9 changes: 7 additions & 2 deletions internal/api/tscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ type tsCacheGroup struct {
shutdown func()
}

func newTSCacheGroup(approxMaxSize int, lodTables map[string]map[int64]string, utcOffset int64, loader tsLoadFunc) *tsCacheGroup {
func newTSCacheGroup(approxMaxSize int, lodTables map[string]map[int64]string, utcOffset int64, loader tsLoadFunc, dropEvery time.Duration) *tsCacheGroup {
g := &tsCacheGroup{
pointCaches: map[string]map[int64]*tsCache{},
}

for version, tables := range lodTables {
drop := dropEvery
if version == Version2 {
drop = 0 // NB! WHY??
}

g.pointCaches[version] = map[int64]*tsCache{}
for stepSec := range tables {
now := time.Now()
Expand All @@ -70,7 +75,7 @@ func newTSCacheGroup(approxMaxSize int, lodTables map[string]map[int64]string, u
cache: map[string]*tsEntry{},
invalidatedAtNano: map[int64]int64{},
lastDrop: now,
dropEvery: data_model.CacheDropInterval(version),
dropEvery: drop,
bytesAlloc: statshouse.GetMetricRef(format.BuiltinMetricAPICacheBytesAlloc, statshouse.Tags{
1: srvfunc.HostnameForStatshouse(), 2: version, 3: strconv.FormatInt(stepSec, 10),
}),
Expand Down
9 changes: 0 additions & 9 deletions internal/data_model/timescale.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,6 @@ var (

var errQueryOutOfRange = fmt.Errorf("exceeded maximum resolution of %d points per timeseries", MaxSlice)

func CacheDropInterval(version string) time.Duration {
switch version {
case Version1:
return 90 * time.Second
default:
return 0
}
}

func GetTimescale(args GetTimescaleArgs) (Timescale, error) {
if args.End <= args.Start || args.Step < 0 {
return Timescale{}, nil
Expand Down