mirror of https://gitee.com/bigwinds/arangodb
issue #1099: do not fail if general-graph.remove is used inside a transaction
This commit is contained in:
parent
32c1404eec
commit
548f8137cc
|
@ -62,8 +62,9 @@ namespace triagens {
|
|||
std::vector<std::string> const& readCollections,
|
||||
std::vector<std::string> const& writeCollections,
|
||||
double lockTimeout,
|
||||
bool waitForSync)
|
||||
: Transaction(new V8TransactionContext(false), vocbase, 0) {
|
||||
bool waitForSync,
|
||||
bool embed)
|
||||
: Transaction(new V8TransactionContext(embed), vocbase, 0) {
|
||||
|
||||
// std::cout << TRI_CurrentThreadId() << ", EXPLICITTRANSACTION " << this << " CTOR\r\n";
|
||||
this->addHint(TRI_TRANSACTION_HINT_LOCK_ENTIRELY, false);
|
||||
|
|
|
@ -277,6 +277,11 @@ static v8::Handle<v8::Value> JS_Transaction (v8::Arguments const& argv) {
|
|||
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
bool embed = false;
|
||||
if (object->Has(TRI_V8_SYMBOL("embed"))) {
|
||||
v8::Handle<v8::Value> v = v8::Handle<v8::Object>::Cast(object->Get(TRI_V8_SYMBOL("embed")));
|
||||
embed = TRI_ObjectToBoolean(v);
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> current = v8::Context::GetCurrent()->Global();
|
||||
|
||||
|
@ -306,13 +311,13 @@ static v8::Handle<v8::Value> JS_Transaction (v8::Arguments const& argv) {
|
|||
TRI_V8_EXCEPTION_PARAMETER(scope, actionError);
|
||||
}
|
||||
|
||||
|
||||
// start actual transaction
|
||||
ExplicitTransaction trx(vocbase,
|
||||
readCollections,
|
||||
writeCollections,
|
||||
lockTimeout,
|
||||
waitForSync);
|
||||
waitForSync,
|
||||
embed);
|
||||
|
||||
int res = trx.begin();
|
||||
|
||||
|
|
|
@ -1911,7 +1911,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
|
||||
// remove
|
||||
wrap.remove = function(edgeId, options) {
|
||||
var result;
|
||||
//if _key make _id (only on 1st call)
|
||||
if (edgeId.indexOf("/") === -1) {
|
||||
edgeId = key + "/" + edgeId;
|
||||
|
@ -1923,6 +1922,7 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
collections: {
|
||||
write: self.__collectionsToLock
|
||||
},
|
||||
embed: true,
|
||||
action: function (params) {
|
||||
var db = require("internal").db;
|
||||
params.ids.forEach(
|
||||
|
@ -1940,13 +1940,15 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
options: options
|
||||
}
|
||||
});
|
||||
result = true;
|
||||
} catch (e) {
|
||||
result = false;
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
throw e;
|
||||
}
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
return result;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
self[key] = wrap;
|
||||
|
@ -1956,7 +1958,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
var bindVertexCollections = function(self, vertexCollections) {
|
||||
_.each(vertexCollections, function(key) {
|
||||
var obj = db._collection(key);
|
||||
var result;
|
||||
var wrap = wrapCollection(obj);
|
||||
wrap.remove = function(vertexId, options) {
|
||||
//delete all edges using the vertex in all graphs
|
||||
|
@ -1998,6 +1999,7 @@ var bindVertexCollections = function(self, vertexCollections) {
|
|||
collections: {
|
||||
write: self.__collectionsToLock
|
||||
},
|
||||
embed: true,
|
||||
action: function (params) {
|
||||
var db = require("internal").db;
|
||||
params.ids.forEach(
|
||||
|
@ -2021,14 +2023,15 @@ var bindVertexCollections = function(self, vertexCollections) {
|
|||
vertexId: vertexId
|
||||
}
|
||||
});
|
||||
result = true;
|
||||
} catch (e) {
|
||||
result = false;
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
throw e;
|
||||
}
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
|
||||
return result;
|
||||
return true;
|
||||
};
|
||||
self[key] = wrap;
|
||||
});
|
||||
|
|
|
@ -1910,7 +1910,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
|
||||
// remove
|
||||
wrap.remove = function(edgeId, options) {
|
||||
var result;
|
||||
//if _key make _id (only on 1st call)
|
||||
if (edgeId.indexOf("/") === -1) {
|
||||
edgeId = key + "/" + edgeId;
|
||||
|
@ -1922,6 +1921,7 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
collections: {
|
||||
write: self.__collectionsToLock
|
||||
},
|
||||
embed: true,
|
||||
action: function (params) {
|
||||
var db = require("internal").db;
|
||||
params.ids.forEach(
|
||||
|
@ -1939,13 +1939,15 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
options: options
|
||||
}
|
||||
});
|
||||
result = true;
|
||||
} catch (e) {
|
||||
result = false;
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
throw e;
|
||||
}
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
return result;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
self[key] = wrap;
|
||||
|
@ -1955,7 +1957,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
|
|||
var bindVertexCollections = function(self, vertexCollections) {
|
||||
_.each(vertexCollections, function(key) {
|
||||
var obj = db._collection(key);
|
||||
var result;
|
||||
var wrap = wrapCollection(obj);
|
||||
wrap.remove = function(vertexId, options) {
|
||||
//delete all edges using the vertex in all graphs
|
||||
|
@ -1997,6 +1998,7 @@ var bindVertexCollections = function(self, vertexCollections) {
|
|||
collections: {
|
||||
write: self.__collectionsToLock
|
||||
},
|
||||
embed: true,
|
||||
action: function (params) {
|
||||
var db = require("internal").db;
|
||||
params.ids.forEach(
|
||||
|
@ -2020,14 +2022,15 @@ var bindVertexCollections = function(self, vertexCollections) {
|
|||
vertexId: vertexId
|
||||
}
|
||||
});
|
||||
result = true;
|
||||
} catch (e) {
|
||||
result = false;
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
throw e;
|
||||
}
|
||||
self.__idsToRemove = [];
|
||||
self.__collectionsToLock = [];
|
||||
|
||||
return result;
|
||||
return true;
|
||||
};
|
||||
self[key] = wrap;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue