You shouldn&#x27;t be downvoted; people should help you get up to speed.<p>In the scenario you describe, the database commit works, you send the email but... you get an error back from the email send function. Now what?<p>This is a basic distributed computing problem. Choosing how to solve it can have a drastic effect on your code and your infrastructure. If the secondary function is &quot;charge a credit card&quot; obviously you can&#x27;t do that twice. But if it&#x27;s merely &quot;send an email&quot; then maybe it&#x27;s okay if people get a duplicate.<p>Google lease&#x2F;lock&#x2F;deadlock&#x2F;race condition and read up on why databases tend to make for bad implementations.