mirror of https://github.com/milvus-io/milvus.git
Refactor snapshot of timestamp statistics (#6600)
Signed-off-by: dragondriver <jiquan.long@zilliz.com>pull/6600/merge
parent
a7b27db63e
commit
0e2329c7ad
|
@ -205,7 +205,7 @@ type DdTaskQueue struct {
|
||||||
|
|
||||||
type pChanStatInfo struct {
|
type pChanStatInfo struct {
|
||||||
pChanStatistics
|
pChanStatistics
|
||||||
refCnt int
|
tsSet map[Timestamp]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DmTaskQueue struct {
|
type DmTaskQueue struct {
|
||||||
|
@ -258,7 +258,9 @@ func (queue *DmTaskQueue) addPChanStats(t task) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
info = &pChanStatInfo{
|
info = &pChanStatInfo{
|
||||||
pChanStatistics: stat,
|
pChanStatistics: stat,
|
||||||
refCnt: 1,
|
tsSet: map[Timestamp]struct{}{
|
||||||
|
stat.minTs: {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
queue.pChanStatisticsInfos[cName] = info
|
queue.pChanStatisticsInfos[cName] = info
|
||||||
} else {
|
} else {
|
||||||
|
@ -268,7 +270,7 @@ func (queue *DmTaskQueue) addPChanStats(t task) error {
|
||||||
if info.maxTs < stat.maxTs {
|
if info.maxTs < stat.maxTs {
|
||||||
queue.pChanStatisticsInfos[cName].maxTs = stat.maxTs
|
queue.pChanStatisticsInfos[cName].maxTs = stat.maxTs
|
||||||
}
|
}
|
||||||
queue.pChanStatisticsInfos[cName].refCnt++
|
queue.pChanStatisticsInfos[cName].tsSet[info.minTs] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.statsLock.Unlock()
|
queue.statsLock.Unlock()
|
||||||
|
@ -288,9 +290,17 @@ func (queue *DmTaskQueue) popPChanStats(t task) error {
|
||||||
for _, cName := range channels {
|
for _, cName := range channels {
|
||||||
info, ok := queue.pChanStatisticsInfos[cName]
|
info, ok := queue.pChanStatisticsInfos[cName]
|
||||||
if ok {
|
if ok {
|
||||||
info.refCnt--
|
delete(queue.pChanStatisticsInfos[cName].tsSet, info.minTs)
|
||||||
if info.refCnt <= 0 {
|
if len(queue.pChanStatisticsInfos[cName].tsSet) <= 0 {
|
||||||
delete(queue.pChanStatisticsInfos, cName)
|
delete(queue.pChanStatisticsInfos, cName)
|
||||||
|
} else if queue.pChanStatisticsInfos[cName].minTs == info.minTs {
|
||||||
|
minTs := info.maxTs
|
||||||
|
for ts := range queue.pChanStatisticsInfos[cName].tsSet {
|
||||||
|
if ts < minTs {
|
||||||
|
minTs = ts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queue.pChanStatisticsInfos[cName].minTs = minTs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue