mirror of https://github.com/milvus-io/milvus.git
fix: incorrect memory size and delta count in SegmentInfo (#35369)
issue: #35368 Signed-off-by: jaime <yun.zhang@zilliz.com>pull/35377/head
parent
196b343a94
commit
1b0ea49d25
|
@ -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…
Reference in New Issue