After sequelize enabled the transaction, the isolation level was set to dirty read, but there was no data problem.

there is a table in the database. I read this table first. If there is anything that meets the conditions, I will directly return. If not, update a piece of data. Now, if two requests come in, neither of them will read the qualified data. The expected result is that the first request is not read, one will be updated, and the second request should read the result of the first insert. According to the netizen"s suggestion, I opened the transaction and set it to read dirty, but the result is still the same, the following code:

        sequlize.transaction({ autocommit: true, isolationLevel: sequlize.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED }, async function (t) {
            //
            return sequlize.models.chat_user.findOne({ where: { url: data.url, have_vest: 1, vest_name: data.vest_name, online: 1, room: room }, raw: true, transaction: t })
                .then(function (vest) {
                    if (vest) {
                        io.sockets.connected[socket.id].emit("rob_vest", { success: false, message: "not avilable vest" })
                        // return sequlize.Promise.reject();
                        return
                    }
                    return sequlize.models.used_vest.findOne({ where: { phone, room, url }, raw: true, transaction: t })
                        .then(async function (cool_vest) {
                            //
                            if (!cool_vest) {
                                console.log("*userd_time", vest_time)
                                let used_time = vest_time
                                console.log("userddddddddtime------------------", used_time)
                                let data = await sequlize.models.used_vest.create({ phone, room, url, used_time })
                            }
                            return sequlize.models.chat_user.update({ have_vest: 1, url: data.url, vest_name: data.vest_name, vest_time: vest_time, room: room }, { where: { phone }, raw: true, transaction: t })
                                .then(function (update_user) {
                                    console.log("")
                                    if (update_user) {
                                        //
                                        io.to(room).emit("rob_vest", { success: true, phone: phone })
                                        schedules.addListenVest(io)
                                    } else {
                                        //
                                        io.sockets.connected[socket.id].emit("rob_vest", { success: false, phone: phone })

                                    }
                                })
                        })
                });
        }).then(function (results) {
            /*  */
            console.log("")
        }).catch(function (err) {
            /*  */
            throw err
            console.log("", err)
        });;
    },
The table of

operation is the chat_ user table, and two requests come in at the same time. As a result, two pieces of data are updated

.
Apr.19,2021

READ_UNCOMMITTED doesn't stop it. Request 1 reads table1 , request 2 reads table1 , request 1 updates table1 , request 2 updates table1 .

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