I saw a piece of code and started to get confused. Help me out if you have any experience with the same.
I have a trigger on the Lead object. So, When Lead Email get's update, I publish a platform event to update some other record.
Once above platform event [ myEvent__e ] is published. The trigger on this myEvent__e gets executed.
This trigger on myEvent__e updates a record of Object [ UpdatedEmails__c ] that is not related to lead object. It just takes some info of lead records from the received platform event.
Hope that scenario is clear.
Now question is If DML Inside my second trigger logic [ myEvent__e ] throws an exception. ( with no try/catch block ). Will the transaction Rollback? Or will the lead update revert to its original state?
My Findings: I observed that The first trigger logic on lead till firing platform event is coming under my user logs. And After that, debug logs are coming under automation user.
That means they are two different transactions and exceptions will not rollback completely.
Thanks in advance!