Transaction exceeded limit: got 24179504, limit 16777216

What did I wrong?

deleteWeb: Do(
  Delete(Ref(Collection('webs'), selectInput('id'))),
  FMap(
    Paginate(
      Match(
        Index('pages_by_web_sort_by_created_asc'),
        Ref(Collection('webs'), selectInput('id')),
      ),
      { size: AppConfig.maxPagesPerWeb },
    ),
    Lambda(['created', 'ref'], Delete(Var('ref'))),
  ),
  FMap(
    Paginate(
      Match(
        Index('importPageQueue_by_web_sort_by_created_asc'),
        Ref(Collection('webs'), selectInput('id')),
      ),
      { size: AppConfig.maxPagesPerWeb },
    ),
    Lambda(['created', 'ref', 'url'], Delete(Var('ref'))),
  ),
  true,
),

I think I know where is the problem. Delete returns deleted data. I tried a simpler example which was fixed when I explicitly used Do(Delete(…), true) to return nothing.

I suppose https://docs.fauna.com/fauna/current/api/fql/functions/delete#returns docs is wrong.

There is a 16MB limit on transactions, which might be where 16777216 is coming from. This is hinted here, in Data Manager docs. Maybe somewhere else, but I can’t find it. I dug this up from conversations slack.

Also,

There is definitely something wrong with the Delete docs.

As an aside,

You hid your original question by updating it with your answer. What you are saying to readers is that this code block is not working. But later you suggest that this is actually the code that does work. This was very confusing. It would be better to provide the new code in a later post and mark it as the solution. You did explain you figured it out, but why not put the working code there?

Also, what is FMAP? Or selectInput? When I first looked at this question, I read the original post first, and my instincts are to respond, “I cannot say with any certainty what is wrong until you explain what these external functions do”. It does look like your question is answered, and the transaction limit is recorded for everyone, so no need to dwell on this part. But it would be helpful if you can sanitize your code a little more when uploading to questions, because it is most likely other readers will not be familiar with you more bespoke library calls.

FMap is just an alias to Map, check this proposal https://github.com/fauna/faunadb-js/issues/270.

// just a helper
const selectInput = (path: ExprArg) => Select(path, Var('input'));

Sorry for the suboptimal issue explanation.

This is the working code. I put true to both FMap (Map alias) and it somehow fixed the limit. It should not, because it’s semantically the same.

deleteWeb: Do(
    Delete(Ref(Collection('webs'), selectInput('id'))),
    FMap(
      Paginate(
        Match(
          Index('pages_by_web_sort_by_created_asc'),
          Ref(Collection('webs'), selectInput('id')),
        ),
        { size: AppConfig.maxPagesPerWeb },
      ),
      // https://forums.fauna.com/t/transaction-exceeded-limit-got-24179504-limit-16777216/227
      Lambda(['created', 'ref'], Do(Delete(Var('ref')), true)),
    ),
    FMap(
      Paginate(
        Match(
          Index('importPageQueue_by_web_sort_by_created_asc'),
          Ref(Collection('webs'), selectInput('id')),
        ),
        { size: AppConfig.maxPagesPerWeb },
      ),
      // https://forums.fauna.com/t/transaction-exceeded-limit-got-24179504-limit-16777216/227
      Lambda(['created', 'ref', 'url'], Do(Delete(Var('ref')), true)),
    ),
    true,
  ),

But I don’t have a failing repo to demonstrate it, so feel free to ignore it until I will have one.

The 16MB limit on transactions should be described somewhere in docs anyway. Thank you.

Yes it should, and I’m sorry for the confusion. This limit was actually pushed in hot to fix an outage which is why the docs are lagging a little, we normally wouldn’t push a breaking update without updating the docs first. :bowing_man: