Skip to content

Commit

Permalink
fix(core): Update error msg for txn too old to give more context (#9170)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
harshil-goel committed Oct 7, 2024
1 parent 1b2af87 commit 2554242
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions posting/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion posting/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ func (qs *queryState) handleUidPostings(
}
len := pl.Length(args.q.ReadTs, 0)
if len == -1 {
return posting.ErrTsTooOld
return errors.Wrapf(posting.ErrTsTooOld, "While reading posting list length")
}
count := int64(len)
if evalCompare(srcFn.fname, count, srcFn.threshold[0]) {
Expand Down

0 comments on commit 2554242

Please sign in to comment.