How to deal with redis if the database operation fails in the e-commerce second kill system?

when working on a project with reference to the materials on the Internet, if the last step of generating a kill order to the database fails because of the database itself, but the inventory in redis has been reduced and redis can not be rolled back, how to deal with redis in this case?

Jul.08,2022

should be locked first, and then unlocked after the database is updated successfully with the new redis data. Here


you can add a loop. If the database fails to retry, you can put it in queue if you have mq, and automatically retry


add pessimistic lock setnx

.
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-7ab832-28d8b.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-7ab832-28d8b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?