mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
fix: incorrect memory size and delta count in SegmentInfo (#35370)
issue: #35368 pr: #35369 Signed-off-by: jaime <yun.zhang@zilliz.com>
This commit is contained in:
parent
e3cb994ca3
commit
623f9d3c53
@ -473,8 +473,9 @@ func SetLevel(level datapb.SegmentLevel) SegmentInfoOption {
|
||||
}
|
||||
}
|
||||
|
||||
// getSegmentSize use cached value when segment is immutable
|
||||
func (s *SegmentInfo) getSegmentSize() int64 {
|
||||
if s.size.Load() <= 0 || s.GetState() == commonpb.SegmentState_Growing {
|
||||
if s.size.Load() <= 0 || s.GetState() != commonpb.SegmentState_Flushed {
|
||||
var size int64
|
||||
for _, binlogs := range s.GetBinlogs() {
|
||||
for _, l := range binlogs.GetBinlogs() {
|
||||
@ -500,8 +501,9 @@ func (s *SegmentInfo) getSegmentSize() int64 {
|
||||
return s.size.Load()
|
||||
}
|
||||
|
||||
// getDeltaCount use cached value when segment is immutable
|
||||
func (s *SegmentInfo) getDeltaCount() int64 {
|
||||
if s.deltaRowcount.Load() < 0 {
|
||||
if s.deltaRowcount.Load() < 0 || s.State != commonpb.SegmentState_Flushed {
|
||||
var rc int64
|
||||
for _, deltaLogs := range s.GetDeltalogs() {
|
||||
for _, l := range deltaLogs.GetBinlogs() {
|
||||
|
||||
@ -97,6 +97,46 @@ func TestCompactionTo(t *testing.T) {
|
||||
assert.Nil(t, s)
|
||||
}
|
||||
|
||||
func TestGetSegmentSize(t *testing.T) {
|
||||
segment := &SegmentInfo{
|
||||
SegmentInfo: &datapb.SegmentInfo{
|
||||
Binlogs: []*datapb.FieldBinlog{
|
||||
{
|
||||
Binlogs: []*datapb.Binlog{
|
||||
{
|
||||
LogID: 1,
|
||||
MemorySize: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Statslogs: []*datapb.FieldBinlog{
|
||||
{
|
||||
Binlogs: []*datapb.Binlog{
|
||||
{
|
||||
LogID: 1,
|
||||
MemorySize: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Deltalogs: []*datapb.FieldBinlog{
|
||||
{
|
||||
Binlogs: []*datapb.Binlog{
|
||||
{
|
||||
LogID: 1,
|
||||
MemorySize: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, int64(3), segment.getSegmentSize())
|
||||
assert.Equal(t, int64(3), segment.getSegmentSize())
|
||||
}
|
||||
|
||||
func TestIsDeltaLogExists(t *testing.T) {
|
||||
segment := &SegmentInfo{
|
||||
SegmentInfo: &datapb.SegmentInfo{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user