mirror of https://gitee.com/bigwinds/arangodb
Bug fix/allow creating foxx queues inside transactions (#8339)
* allow creating a foxx queue from within a transaction * added tests
This commit is contained in:
parent
e28b908bbe
commit
9f9426e36c
|
@ -357,7 +357,7 @@ static void JS_CreateQueue(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
|
||||
LOG_TOPIC(TRACE, Logger::FIXME) << "Adding queue " << key;
|
||||
ExecContextScope exscope(ExecContext::superuser());
|
||||
auto ctx = transaction::V8Context::Create(*vocbase, false);
|
||||
auto ctx = transaction::V8Context::Create(*vocbase, true);
|
||||
SingleCollectionTransaction trx(ctx, "_queues", AccessMode::Type::EXCLUSIVE);
|
||||
Result res = trx.begin();
|
||||
|
||||
|
@ -410,7 +410,7 @@ static void JS_DeleteQueue(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
|
||||
LOG_TOPIC(TRACE, Logger::FIXME) << "Removing queue " << key;
|
||||
ExecContextScope exscope(ExecContext::superuser());
|
||||
auto ctx = transaction::V8Context::Create(*vocbase, false);
|
||||
auto ctx = transaction::V8Context::Create(*vocbase, true);
|
||||
SingleCollectionTransaction trx(ctx, "_queues", AccessMode::Type::WRITE);
|
||||
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
|
||||
Result res = trx.begin();
|
||||
|
|
|
@ -147,7 +147,7 @@ static void JS_LastLoggerReplication(v8::FunctionCallbackInfo<v8::Value> const&
|
|||
TRI_V8_THROW_EXCEPTION_USAGE("tickStart < tickEnd");
|
||||
}
|
||||
|
||||
auto transactionContext = transaction::V8Context::Create(vocbase, false);
|
||||
auto transactionContext = transaction::V8Context::Create(vocbase, true);
|
||||
auto builderSPtr = std::make_shared<VPackBuilder>();
|
||||
Result res = EngineSelectorFeature::ENGINE->lastLogger(vocbase, transactionContext,
|
||||
tickStart, tickEnd, builderSPtr);
|
||||
|
|
|
@ -53,6 +53,30 @@ function foxxQueuesSuite () {
|
|||
db._drop(cn);
|
||||
queues.delete(qn);
|
||||
},
|
||||
|
||||
testCreateQueueInsideTransactionNoCollectionDeclaration : function () {
|
||||
try {
|
||||
db._executeTransaction({
|
||||
collections: {},
|
||||
action: function() {
|
||||
queues.create(qn);
|
||||
}
|
||||
});
|
||||
fail();
|
||||
} catch (err) {
|
||||
assertEqual(internal.errors.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
||||
testCreateQueueInsideTransactionWithCollectionDeclaration : function () {
|
||||
db._executeTransaction({
|
||||
collections: { write: ["_queues"] },
|
||||
action: function() {
|
||||
queues.create(qn);
|
||||
}
|
||||
});
|
||||
assertEqual([], queues.get(qn).all());
|
||||
},
|
||||
|
||||
testCreateEmptyQueue : function () {
|
||||
var queue = queues.create(qn);
|
||||
|
|
Loading…
Reference in New Issue