Skip to content

Commit 2554242

Browse files
committed
fix(core): Update error msg for txn too old to give more context (#9170)
Update rollup frequency so that txn too old error doesn't happen too frequently. Also added more context to the error to see where it's coming from.
1 parent 1b2af87 commit 2554242

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

posting/index.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func (txn *Txn) addReverseMutationHelper(ctx context.Context, plist *List,
243243
if hasCountIndex {
244244
countBefore, found, _ = plist.getPostingAndLengthNoSort(txn.StartTs, 0, edge.ValueId)
245245
if countBefore == -1 {
246-
return emptyCountParams, ErrTsTooOld
246+
return emptyCountParams, errors.Wrapf(ErrTsTooOld, "Adding reverse mutation helper count")
247247
}
248248
}
249249
if err := plist.addMutationInternal(ctx, txn, edge); err != nil {
@@ -505,7 +505,7 @@ func (txn *Txn) addMutationHelper(ctx context.Context, l *List, doUpdateIndex bo
505505
case hasCountIndex:
506506
countBefore, found, currPost = l.getPostingAndLength(txn.StartTs, 0, getUID(t))
507507
if countBefore == -1 {
508-
return val, false, emptyCountParams, ErrTsTooOld
508+
return val, false, emptyCountParams, errors.Wrapf(ErrTsTooOld, "Add mutation count index")
509509
}
510510
case doUpdateIndex || delNonListPredicate:
511511
found, currPost, err = l.findPosting(txn.StartTs, fingerprintEdge(t))

posting/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ func (l *List) Uids(opt ListOptions) (*pb.List, error) {
12781278
if len(l.mutationMap) == 0 && opt.Intersect != nil && len(l.plist.Splits) == 0 {
12791279
if opt.ReadTs < l.minTs {
12801280
l.RUnlock()
1281-
return out, ErrTsTooOld
1281+
return out, errors.Wrapf(ErrTsTooOld, "While reading UIDs")
12821282
}
12831283
algo.IntersectCompressedWith(l.plist.Pack, opt.AfterUid, opt.Intersect, out)
12841284
l.RUnlock()

posting/mvcc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (ir *incrRollupi) Process(closer *z.Closer, getNewTs func(bool) uint64) {
195195
currTs := time.Now().Unix()
196196
for _, key := range *batch {
197197
hash := z.MemHash(key)
198-
if elem := m[hash]; currTs-elem >= 2 {
198+
if elem := m[hash]; currTs-elem >= 10 {
199199
// Key not present or Key present but last roll up was more than 2 sec ago.
200200
// Add/Update map and rollup.
201201
m[hash] = currTs

worker/task.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ func (qs *queryState) handleUidPostings(
854854
}
855855
len := pl.Length(args.q.ReadTs, 0)
856856
if len == -1 {
857-
return posting.ErrTsTooOld
857+
return errors.Wrapf(posting.ErrTsTooOld, "While reading posting list length")
858858
}
859859
count := int64(len)
860860
if evalCompare(srcFn.fname, count, srcFn.threshold[0]) {

0 commit comments

Comments
 (0)