Including the range scan permission ? Because read/write, yes of course, but because the term used in the doc is « scan », I’m wondering.
Ah I can see why you may think that, but no, just KV read and write permissions.
So have a long-running process that will do nothing else but the cleanup. That’s basically a cleanup app 
Yes, can call it that certainly. We do have longer term plans to improve the experience in this regard for our lambda users, and this request has come up a few times. So I hope that we will have a better story for you in the future, but for now, a dedicated cleanup app is required.
That cleanup lambda invocation could be scheduled on an appropriate interval.
AFAIU you need to cleanup only to remove tiny documents, it’s not blocking anything, is it ? Or does it prevent any new transaction to be performed on the documents involved in the transaction that needs a cleanup ?
Usually cleanup will have nothing to do at all. At the point your transactions().run() call returns, we aim to have completely cleaned up the transaction, including removing any of the metadata associated with it.
Cleanup is for the cases where things go wrong - it’s intended to be a robust ‘backstop’ to cover any corner case, such as if your application crashes, for instance, or the transaction times out mid-commit. So we should be talking about fairly rare situations.
Without wanting to reveal too many internal details (as we need flexibility to make future changes at the protocol level), cleanup currently works by looking for expired transactions via reading a distributed index, and if it finds any, picking up wherever the app left off. Usually it will find these ‘lost’ transactions within 60 seconds of them expiring - that is configurable and can be tuned to be more aggressive, at the cost of a slightly higher rate of reads (to locate the transactions).
And yes, in the rare cases of a ‘lost’ transaction, and only if that lost transaction had reached the commit point, then any docs it has staged will be locked from transactional writes (not reads) until cleanup finds them. So having cleanup running is a critical part of the infra.
Hopefully that also explains why it’s best to have cleanup running continuously, rather than on schedule.
I am concerned that by giving all these details I’m implying that users need to worry about them… For most users, the default cleanup settings should work well out-of-the-box, and require no special tuning.
The exception are users of short-lived applications, such as lambdas and tests. They do require the workaround given above, at present.