One safe way to do this is to select an update line that takes an exceptional lock on the line, send an email, and then update the entry to "t" and commit.
Write lock is the intentional design goal of this method. Until the message is sent, you do not want to indicate that you sent it, otherwise you will need a recovery process to show that the transmission really failed. Similarly, when you started the email sending process, you do not want another session to start this process.
If you need to avoid longer blocking, I would suggest splitting the process into two stages - by setting a flag to confirm that the email transfer process has started (and actually I will mark this time), and set it again (or set another) for transfer confirmation. This is not a bad method in itself, since it allows you to track how long it took to get confirmation, and, in my experience, some internet requests can be a significant part of the applicationโs time.
source share