Skip to content

Commit 8b54856

Browse files
author
Harshil Goel
authored
fix(core): Fix deleteBelowTs rollup issue (#9296)
1 parent 722b1e9 commit 8b54856

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

posting/list.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ type pIterator struct {
507507
}
508508

509509
func (it *pIterator) seek(l *List, afterUid, deleteBelowTs uint64) error {
510-
if deleteBelowTs > 0 && deleteBelowTs <= l.minTs {
510+
// Because we store rollup at commitTs + 1, it could happen that a transaction has a startTs = prev commitTs
511+
// + 1. Within that transcation if there's a delete all, deleteBelowTs (=startT) would be equal to l.minTs
512+
// (rollup timestamp, prev commitTs + 1). So it's allowed deleteBelowTs == l.minTs
513+
if deleteBelowTs > 0 && deleteBelowTs < l.minTs {
511514
return errors.Errorf("deleteBelowTs (%d) must be greater than the minTs in the list (%d)",
512515
deleteBelowTs, l.minTs)
513516
}

worker/task.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,10 @@ func (qs *queryState) handleUidPostings(
838838
}
839839

840840
if srcFn.fnType == compareAttrFn {
841+
pl.RLock()
841842
posting.GetStatsHolder().InsertRecord(
842843
q.Attr, []byte(srcFn.tokens[i]), uint64(pl.ApproxLen()))
844+
pl.RUnlock()
843845
}
844846

845847
switch {
@@ -1831,7 +1833,7 @@ func planForEqFilter(fc *functionContext, pred string, uidlist []uint64) {
18311833
gotEstimate := false
18321834
for _, eqToken := range fc.tokens {
18331835
count := posting.GetStatsHolder().ProcessEqPredicate(pred, []byte(eqToken))
1834-
if count != math.MaxUint64 {
1836+
if count != math.MaxUint64 && count != 0 {
18351837
estimatedCount += count
18361838
gotEstimate = true
18371839
} else {

0 commit comments

Comments
 (0)