提交 260fd984 编写于 作者: U Ulric Qin

fix log collector lost point

上级 001696e0
......@@ -167,7 +167,6 @@ func (psc *PointsCounter) GetBytagstring(tagstring string) (*PointCounter, error
func (psc *PointsCounter) Update(tagstring string, value float64) error {
pointCount, err := psc.GetBytagstring(tagstring)
if err != nil {
psc.Lock()
tmp := new(PointCounter)
tmp.Count = 0
tmp.Sum = 0
......@@ -177,14 +176,15 @@ func (psc *PointsCounter) Update(tagstring string, value float64) error {
}
tmp.Max = math.NaN()
tmp.Min = math.NaN()
psc.TagstringMap[tagstring] = tmp
psc.Unlock()
pointCount, err = psc.GetBytagstring(tagstring)
// 如果还是拿不到,就出错返回吧
if err != nil {
return fmt.Errorf("when update, cannot get pointCount after add [tagstring:%s]", tagstring)
var has bool
psc.Lock()
pointCount, has = psc.TagstringMap[tagstring]
if !has {
psc.TagstringMap[tagstring] = tmp
pointCount = tmp
}
psc.Unlock()
}
pointCount.Lock()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册