I would like to confirm the behaviour of asynchronous apex when an error occurs on its original/parent transaction.
Imagine we have a synchronous apex transaction (Transaction1-Apex) that launches a apex batch process (Transaction2-Batch).
Can I assume that if there is a uncatched exception in Transaction1-Apex after the executeBatch method has been called, the platform will also rollback or even not execute Transaction2-Batch?
Here is a more "graphical" representation of what I mean:
Transaction1-Apex - - - Database.executeBatch(...) Transaction2-Batch - - - - - - Uncatched exception - -- Automatic rollback ... is this transaction also rolled back?
I assumed that was the case, asynchronous apex was always rolled back. However, I could not find confirmation in the official docs, then I found the following article indicating that there are some cases where this might not be true: https://smgoodyear.com/2015/12/04/asynchronous-apex-and-transaction-boundaries/
Has anyone investigated this in depth? If so, could you confirm or deny my hypothesis?
Thanks a lot everyone!