How to ensure the atomicity of the program?

I don"t know if you have encountered a situation like this when you are programming. Sometimes we need to file_put_contents two files. How to ensure that both files are either written successfully or failed? or sometimes we need to send the same message to both clients, or both clients succeed, or both fail?

Php
Oct.09,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eac4b9-20c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eac4b9-20c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?