Cannot initialize iterator when calling List.iterate: deleteBelowTs (30308) must be greater than the minTs in the list (30308)"

Report a Dgraph Bug

What version of Dgraph are you using?

v21.12.0

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

256 GB RAM

Ubuntu 21.04

Steps to reproduce the issue (command/config used to run Dgraph).

Occurs almost randomly for a specific mutation. This is a cutdown version of the source code that triggers this issue. All I have to do is run this function over and over again and that error will occur occasionally.

Error is triggered by the error check right after resp, err := txn.Do(ctx, req)

Any help would be appreciated as this error seems to occur almost randomly.

	txn := db.NewTxn()

	q := (`
		query NormalReactToPost($postID: string, $dUid: string) {
			p as var(func:uid($postID)) @filter(eq(Post.postType, ["HEADLINER", "MIND_CLIP", "ORIGINAL"])) {
				uid
				r as Post.reactions @filter(uid_in(Reaction.author, $dUid) AND eq(PostReaction.location, "DEFAULT"))
			}
			Reactions(func:uid(r)) {
				id: uid
			}
		}
	`)

	now := time.Now().UTC()
	reactMuString := fmt.Sprintf(`
		<%s> <User.postReactions> _:x .
		uid(p) <Post.reactions> _:x .
		_:x <dgraph.type> "PostReaction" .
		_:x <dgraph.type> "Reaction" .
		_:x <Reaction.author> <%s> .
		_:x <Reaction.time> "%s".
		_:x <PostReaction.location> "DEFAULT" .
		_:x <PostReaction.post> uid(p) . 
	`, auth.ID, auth.ID, now.Format(time.RFC3339))
	reactMu := &api.Mutation{
		Cond:      "@if(eq(len(r), 0) AND eq(len(p), 1))",
		SetNquads: []byte(reactMuString),
	}

	unreactMu := &api.Mutation{
		Cond:      "@if(eq(len(r), 1))",
		DelNquads: unreactToPostDelNquads(postID, auth.ID),
	}

	req := &api.Request{
		Query: q,
		Vars: map[string]string{
			"$postID": postID,
			"$dUid":   auth.ID,
		},
		Mutations: []*api.Mutation{reactMu, unreactMu},
		CommitNow: true,
	}

	resp, err := txn.Do(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("error executing normalReactToPost transaction: %w", err)
	}

	data := &struct {
		Reactions []*model.Reaction
	}{}
	err = json.Unmarshal(resp.GetJson(), data)
	if err != nil {
		return nil, fmt.Errorf("could not un-marshall data in normalReactToPost: %w", err)
	}

	shouldReact := len(data.Reactions) == 0
	newID, made := resp.Uids["x"]

	if !made && shouldReact {
		return nil, fmt.Errorf("could not normalReactToPost, reason unknown")
	} else if made && !shouldReact {
		return nil, fmt.Errorf("should not have normalReactedToPost but did, check mutation cond")
	}

	if shouldReact {
		return &model.Reaction{
			Author: &model.User{
				ID: auth.ID,
			},
			ID:   newID,
			Time: now,
		}, nil
	} else {
		return &model.Reaction{
			Author: &model.User{
				ID: auth.ID,
			},
			ID:   data.Reactions[0].ID,
			Time: now,
		}, nil
	}