Sequelize transaction with optimistic locking is locking the whole db

I have an API coded with Node.js and I use a SQLite database with Sequelize.

When I make updates, I use a transaction to rollback if something failed during the process.

The code look like this:

return sequelize.transaction(transaction => {
    return tableA.update(DataToUpdateA, {transaction})
        .then(() => {
            return UpdateValueInTableB(DataToUpdateB, {transaction});
        })
        .then(() => {
             // Do some complexe process that can take a while...
            return SomeComplexeProcess();
        })
        .catch(error => {
            // Log the error
        }); 
});

Sometimes the request take times because in SomeComplexeProcess I'm applying NTFS rights on the File System. And I need to roll back value in the database if something went wrong.

The problem is as long as the transaction is not completed the whole database is locked.

So I wanted to implement Optimistic Locking to avoid locking the whole database.

When I update something, the version field is well increment but my whole database still locked during the process.

Here is the configuration of Sequelize:

new Sequelize(username, password, dbName {
    define: {
        freezeTableName: true,
        version: true // Optimistic locking
    },
    host: ...,
    ....
}

Did I do something wrong with my configuration ?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum