Hi @thisisakasolace - welcome to the forum!
I have a request - can you provide a bit more detail for us? I have some ideas about what’s going wrong here, but you could really help us out by providing a bit more information. For example:
-
When you say “randomly returns an errors about conflicting transaction” - what’s the error message? Can you provide a copy-and-paste from the Output window?
-
When you provide a code sample, can you provide enough context to show how you’re using the decorator? When you’re asking about the interaction between your code and a decorator, providing just a snippet from the inside of the function might miss something important!
-
Is it possible for you to provide a Clone link? (It’s OK if not - I understand app source code is often confidential - but if you can it really helps!)
You can find some more suggestions about asking a good question on the forum here and here.
In this particular case, my guess (pending enough information to investigate further) is that your particular access pattern is tripping a lot of transaction conflicts in our Postgres backend. In particular, the access patterns from that repeated get()
probably walks make Postgres more likely to think you’re conflicting with transactions run by other users. @anvil.tables.in_transaction
attempts to retry, but after enough conflicts it will give up. @stefano.menci’s approach does a single scan, which is probably why it works better in a transaction.