mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-08-08 06:17:15 +02:00
update: new metric store dataNotAligned issue fixed
This commit is contained in:
@@ -625,12 +625,9 @@ func (m *MemoryStore) Read(selector util.Selector, metric string, from, to, reso
|
|||||||
|
|
||||||
// data spans the full requested window; every scope's read() writes into the
|
// data spans the full requested window; every scope's read() writes into the
|
||||||
// same index-aligned slice (NaN where it has no value), so aggregation never
|
// same index-aligned slice (NaN where it has no value), so aggregation never
|
||||||
// needs trimming. dataFrom/dataTo track the real (non-NaN) extent of the first
|
// needs trimming. We check each buffer's extent against the original request
|
||||||
// scope seen; later scopes that report a different extent are misaligned. We
|
// and warn if it doesn't cover the full range.
|
||||||
// no longer abort on misalignment — the full NaN-padded window is still
|
|
||||||
// returned for display — but we log it so the condition stays visible.
|
|
||||||
n, data := 0, make([]schema.Float, (to-from)/minfo.Frequency+1)
|
n, data := 0, make([]schema.Float, (to-from)/minfo.Frequency+1)
|
||||||
var dataFrom, dataTo int64
|
|
||||||
|
|
||||||
err := m.root.findBuffers(selector, minfo.offset, func(b *buffer, path []string) error {
|
err := m.root.findBuffers(selector, minfo.offset, func(b *buffer, path []string) error {
|
||||||
cdata, cfrom, cto, err := b.read(from, to, data, false)
|
cdata, cfrom, cto, err := b.read(from, to, data, false)
|
||||||
@@ -638,26 +635,24 @@ func (m *MemoryStore) Read(selector util.Selector, metric string, from, to, reso
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if n == 0 {
|
// Check if buffer covers full requested range
|
||||||
dataFrom, dataTo = cfrom, cto
|
missingfront := int((cfrom - from) / minfo.Frequency)
|
||||||
} else if cfrom != dataFrom || cto != dataTo {
|
missingback := int((to - cto) / minfo.Frequency)
|
||||||
|
if missingfront > 0 || missingback > 0 {
|
||||||
node := strings.Join(path, "/")
|
node := strings.Join(path, "/")
|
||||||
missingfront, missingback := int((dataFrom-cfrom)/minfo.Frequency), int((dataTo-cto)/minfo.Frequency)
|
|
||||||
switch {
|
switch {
|
||||||
case missingfront != 0:
|
case missingfront > 0 && missingback > 0:
|
||||||
cclog.Warnf("%s", fmt.Errorf("%w: metric=%s node=%s buf#%d freq=%d expected[%d,%d] actual[%d,%d] missingfront=%d pts",
|
cclog.Warnf("%v: metric=%s node=%s requested[%d,%d] actual[%d,%d] missing_front=%d pts missing_back=%d pts",
|
||||||
ErrDataDoesNotAlignMissingFront, metric, node, n, minfo.Frequency, dataFrom, dataTo, cfrom, cto, missingfront))
|
ErrDataDoesNotAlignMissingFront, metric, node, from, to, cfrom, cto, missingfront, missingback)
|
||||||
case missingback != 0:
|
case missingfront > 0:
|
||||||
cclog.Warnf("%s", fmt.Errorf("%w: metric=%s node=%s buf#%d freq=%d expected[%d,%d] actual[%d,%d] missingback=%d pts",
|
cclog.Warnf("%v: metric=%s node=%s requested[%d,%d] actual[%d,%d] missing_front=%d pts",
|
||||||
ErrDataDoesNotAlignMissingBack, metric, node, n, minfo.Frequency, dataFrom, dataTo, cfrom, cto, missingback))
|
ErrDataDoesNotAlignMissingFront, metric, node, from, to, cfrom, cto, missingfront)
|
||||||
default:
|
case missingback > 0:
|
||||||
cclog.Warnf("%s", fmt.Errorf("%w: metric=%s node=%s buf#%d expected[%d,%d] actual[%d,%d]",
|
cclog.Warnf("%v: metric=%s node=%s requested[%d,%d] actual[%d,%d] missing_back=%d pts",
|
||||||
ErrDataDoesNotAlignDataLenMismatch, metric, node, n, dataFrom, dataTo, cfrom, cto))
|
ErrDataDoesNotAlignMissingBack, metric, node, from, to, cfrom, cto, missingback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Gather data - cto: %d, cfrom: %d, dto: %d, dfrom: %d\n", cto, cfrom, dataTo, dataFrom)
|
|
||||||
|
|
||||||
data = cdata
|
data = cdata
|
||||||
n += 1
|
n += 1
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -144,10 +144,10 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6
|
|||||||
if n == 0 {
|
if n == 0 {
|
||||||
from, to = cfrom, cto
|
from, to = cfrom, cto
|
||||||
} else if from != cfrom {
|
} else if from != cfrom {
|
||||||
return fmt.Errorf("%w: metric=%s node=%s buf#%d expected[%d,%d] actual[%d,%d]",
|
return fmt.Errorf("stats: %w: metric=%s node=%s buf#%d expected[%d,%d] actual[%d,%d]",
|
||||||
ErrDataDoesNotAlignMissingFront, metric, strings.Join(path, "/"), n, from, to, cfrom, cto)
|
ErrDataDoesNotAlignMissingFront, metric, strings.Join(path, "/"), n, from, to, cfrom, cto)
|
||||||
} else if to != cto {
|
} else if to != cto {
|
||||||
return fmt.Errorf("%w: metric=%s node=%s buf#%d expected[%d,%d] actual[%d,%d]",
|
return fmt.Errorf("stats: %w: metric=%s node=%s buf#%d expected[%d,%d] actual[%d,%d]",
|
||||||
ErrDataDoesNotAlignMissingBack, metric, strings.Join(path, "/"), n, from, to, cfrom, cto)
|
ErrDataDoesNotAlignMissingBack, metric, strings.Join(path, "/"), n, from, to, cfrom, cto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user