Skip to content

Commit

Permalink
fix Size() duplicate counting rows size. (#17148)
Browse files Browse the repository at this point in the history
之前统计 partition state 里面的 rows 时,使用的是 row.Batch 的地址昨晚去重的手段,绝大多数情况下没有问题,但一条记录也可能会重复推到 CN,不属于同一个 logtail, 自然也不属于同一个 batch,所以就做不到去重的目的。现在使用 rowid 去重。

Approved by: @XuPeng-SH, @heni02
  • Loading branch information
gouhongshen authored Jun 26, 2024
1 parent 7c7176c commit 9afeeec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
17 changes: 2 additions & 15 deletions pkg/vm/engine/disttae/txn_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,34 +217,21 @@ func (tbl *txnTable) Size(ctx context.Context, columnName string) (uint64, error
}
})

// Different rows may belong to same batch. So we have
// to record the batch which we have already handled to avoid
// repetitive computation
handled := make(map[*batch.Batch]struct{})
// Calculate the in mem size
// TODO: It might includ some deleted row size
iter := part.NewRowsIter(ts, nil, false)
defer func() { _ = iter.Close() }()
for iter.Next() {
entry := iter.Entry()
if _, ok := deletes[entry.RowID]; ok {
continue
}
if _, ok := handled[entry.Batch]; ok {
continue
}

for i, s := range entry.Batch.Attrs {
if _, ok := neededCols[s]; ok {
szInPart += uint64(entry.Batch.Vecs[i].Size())
szInPart += uint64(entry.Batch.Vecs[i].Size() / entry.Batch.Vecs[i].Length())
}
}
handled[entry.Batch] = struct{}{}
}

//s := e.Stats(ctx, pb.StatsInfoKey{
// DatabaseID: tbl.db.databaseId,
// TableID: tbl.tableId,
//}, true)
s, _ := tbl.Stats(ctx, true)
if s == nil {
return szInPart, nil
Expand Down
2 changes: 1 addition & 1 deletion test/distributed/cases/mo_cloud/mo_cloud.result
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ triggers 0 0 accountadmin
engines 0 0 accountadmin
routines 0 0 accountadmin
parameters 0 0 accountadmin
keywords 747 45171 accountadmin
keywords 747 44820 accountadmin
schema_privileges 0 0 accountadmin
table_privileges 0 0 accountadmin
column_privileges 0 0 accountadmin
Expand Down

0 comments on commit 9afeeec

Please sign in to comment.