繁体   English   中英

ArangoDB事务不会因错误而回滚

[英]ArangoDB Transaction doesn't rollback on error

更新:解决方案。 ARANGODB集群不支持交易。 它仅在单个实例上受支持。

我正在尝试通过arangoJS库使用事务处理功能。 我将介绍的函数只是一个虚拟函数,该函数插入两个记录,然后尝试获取不存在的文档。 获取不存在的文档会产生错误,并且事务必须回滚。 确实,尝试获取不存在的文档后会生成错误。 但是,数据库不会回滚,并且两个插入的文档仍然插入数据库中。 有人知道如何解决吗?

"updateCustomer" : function (options, cb) {
    const action = String(function (params) {
        // This code will be executed inside ArangoDB! 
        const db = require('@arangodb').db;
        const aql = require('@arangodb').aql;
        const customer = db._collection('customer');
        try{
            //insert two documents
            db._query(aql`INSERT ${params.user} INTO ${customer} Return NEW`);
            db._query(aql`INSERT ${params.customer} INTO ${customer} Return NEW`);
            //Get a document that doesn't exist
            customer.document('does-not-exist');
        }catch(e){
            throw new Error("Everything is bad");
        }
    });
    let opts = {
        collections : {
            read : ["customer"],
            write : ["customer"]
        },
        action : action,
        params : {user: options, customer: options},
        lockTimeout : 5
    };
    Arango.transaction(opts,(err, result) => {
        console.log("err: " + err);
        console.log("result: " + JSON.stringify(result));
        return cb(err, result);
    });
}

"transaction" : function (options, cb) {
    utils.dbConnect().transaction(options.collections, options.action, options.params, options.lockTimeout, cb);
}

更新:我在单个实例ArangoDB上尝试了此事务,并且它起作用了。 但是,它在群集上不起作用。 ArangoDB群集上不支持事务处理吗?

单个文档操作在arangodb群集中是原子的。 到目前为止还没有多文档。 我们目前正在为多文档操作开发ACID。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM