From e6daaa619537ca5ff9c0b48256f22e8d11daf5e4 Mon Sep 17 00:00:00 2001 From: Harshil Goel Date: Fri, 13 Sep 2024 21:07:16 +0530 Subject: [PATCH 1/2] fix(core): Update error msg for txn too old to give more context --- posting/index.go | 4 ++-- posting/list.go | 2 +- posting/mvcc.go | 2 +- worker/task.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/posting/index.go b/posting/index.go index 931a140b407..123be08e66e 100644 --- a/posting/index.go +++ b/posting/index.go @@ -243,7 +243,7 @@ func (txn *Txn) addReverseMutationHelper(ctx context.Context, plist *List, if hasCountIndex { countBefore, found, _ = plist.getPostingAndLengthNoSort(txn.StartTs, 0, edge.ValueId) if countBefore == -1 { - return emptyCountParams, ErrTsTooOld + return emptyCountParams, errors.Wrapf(ErrTsTooOld, "Adding reverse mutation helper count") } } if err := plist.addMutationInternal(ctx, txn, edge); err != nil { @@ -505,7 +505,7 @@ func (txn *Txn) addMutationHelper(ctx context.Context, l *List, doUpdateIndex bo case hasCountIndex: countBefore, found, currPost = l.getPostingAndLength(txn.StartTs, 0, getUID(t)) if countBefore == -1 { - return val, false, emptyCountParams, ErrTsTooOld + return val, false, emptyCountParams, errors.Wrapf(ErrTsTooOld, "Add mutation count index") } case doUpdateIndex || delNonListPredicate: found, currPost, err = l.findPosting(txn.StartTs, fingerprintEdge(t)) diff --git a/posting/list.go b/posting/list.go index fef9f478c7f..d6b873112e4 100644 --- a/posting/list.go +++ b/posting/list.go @@ -1278,7 +1278,7 @@ func (l *List) Uids(opt ListOptions) (*pb.List, error) { if len(l.mutationMap) == 0 && opt.Intersect != nil && len(l.plist.Splits) == 0 { if opt.ReadTs < l.minTs { l.RUnlock() - return out, ErrTsTooOld + return out, errors.Wrapf(ErrTsTooOld, "While reading UIDs") } algo.IntersectCompressedWith(l.plist.Pack, opt.AfterUid, opt.Intersect, out) l.RUnlock() diff --git a/posting/mvcc.go b/posting/mvcc.go index e9f53bbed50..335876ae2e7 100644 --- a/posting/mvcc.go +++ b/posting/mvcc.go @@ -195,7 +195,7 @@ func (ir *incrRollupi) Process(closer *z.Closer, getNewTs func(bool) uint64) { currTs := time.Now().Unix() for _, key := range *batch { hash := z.MemHash(key) - if elem := m[hash]; currTs-elem >= 2 { + if elem := m[hash]; currTs-elem >= 10 { // Key not present or Key present but last roll up was more than 2 sec ago. // Add/Update map and rollup. m[hash] = currTs diff --git a/worker/task.go b/worker/task.go index 07997b159b4..e5695eb0b0b 100644 --- a/worker/task.go +++ b/worker/task.go @@ -854,7 +854,7 @@ func (qs *queryState) handleUidPostings( } len := pl.Length(args.q.ReadTs, 0) if len == -1 { - return posting.ErrTsTooOld + return error.Wrapf(posting.ErrTsTooOld, "While reading posting list length") } count := int64(len) if evalCompare(srcFn.fname, count, srcFn.threshold[0]) { From 26ff827346dbe47f9366bfac74fe1114d08c6f84 Mon Sep 17 00:00:00 2001 From: Harshil Goel Date: Fri, 13 Sep 2024 21:11:57 +0530 Subject: [PATCH 2/2] fixed typo --- worker/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/task.go b/worker/task.go index e5695eb0b0b..3b43c207ff7 100644 --- a/worker/task.go +++ b/worker/task.go @@ -854,7 +854,7 @@ func (qs *queryState) handleUidPostings( } len := pl.Length(args.q.ReadTs, 0) if len == -1 { - return error.Wrapf(posting.ErrTsTooOld, "While reading posting list length") + return errors.Wrapf(posting.ErrTsTooOld, "While reading posting list length") } count := int64(len) if evalCompare(srcFn.fname, count, srcFn.threshold[0]) {