1
0
Fork 0

issue #1099: do not fail if general-graph.remove is used inside a transaction

This commit is contained in:
Jan Steemann 2014-11-17 15:47:39 +01:00 committed by Frank Celler
parent 32c1404eec
commit 548f8137cc
4 changed files with 32 additions and 20 deletions

View File

@ -62,8 +62,9 @@ namespace triagens {
std::vector<std::string> const& readCollections, std::vector<std::string> const& readCollections,
std::vector<std::string> const& writeCollections, std::vector<std::string> const& writeCollections,
double lockTimeout, double lockTimeout,
bool waitForSync) bool waitForSync,
: Transaction(new V8TransactionContext(false), vocbase, 0) { bool embed)
: Transaction(new V8TransactionContext(embed), vocbase, 0) {
// std::cout << TRI_CurrentThreadId() << ", EXPLICITTRANSACTION " << this << " CTOR\r\n"; // std::cout << TRI_CurrentThreadId() << ", EXPLICITTRANSACTION " << this << " CTOR\r\n";
this->addHint(TRI_TRANSACTION_HINT_LOCK_ENTIRELY, false); this->addHint(TRI_TRANSACTION_HINT_LOCK_ENTIRELY, false);

View File

@ -277,6 +277,11 @@ static v8::Handle<v8::Value> JS_Transaction (v8::Arguments const& argv) {
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL); 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(); 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); TRI_V8_EXCEPTION_PARAMETER(scope, actionError);
} }
// start actual transaction // start actual transaction
ExplicitTransaction trx(vocbase, ExplicitTransaction trx(vocbase,
readCollections, readCollections,
writeCollections, writeCollections,
lockTimeout, lockTimeout,
waitForSync); waitForSync,
embed);
int res = trx.begin(); int res = trx.begin();

View File

@ -1911,7 +1911,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
// remove // remove
wrap.remove = function(edgeId, options) { wrap.remove = function(edgeId, options) {
var result;
//if _key make _id (only on 1st call) //if _key make _id (only on 1st call)
if (edgeId.indexOf("/") === -1) { if (edgeId.indexOf("/") === -1) {
edgeId = key + "/" + edgeId; edgeId = key + "/" + edgeId;
@ -1923,6 +1922,7 @@ var bindEdgeCollections = function(self, edgeCollections) {
collections: { collections: {
write: self.__collectionsToLock write: self.__collectionsToLock
}, },
embed: true,
action: function (params) { action: function (params) {
var db = require("internal").db; var db = require("internal").db;
params.ids.forEach( params.ids.forEach(
@ -1940,13 +1940,15 @@ var bindEdgeCollections = function(self, edgeCollections) {
options: options options: options
} }
}); });
result = true;
} catch (e) { } catch (e) {
result = false; self.__idsToRemove = [];
self.__collectionsToLock = [];
throw e;
} }
self.__idsToRemove = []; self.__idsToRemove = [];
self.__collectionsToLock = []; self.__collectionsToLock = [];
return result;
return true;
}; };
self[key] = wrap; self[key] = wrap;
@ -1956,7 +1958,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
var bindVertexCollections = function(self, vertexCollections) { var bindVertexCollections = function(self, vertexCollections) {
_.each(vertexCollections, function(key) { _.each(vertexCollections, function(key) {
var obj = db._collection(key); var obj = db._collection(key);
var result;
var wrap = wrapCollection(obj); var wrap = wrapCollection(obj);
wrap.remove = function(vertexId, options) { wrap.remove = function(vertexId, options) {
//delete all edges using the vertex in all graphs //delete all edges using the vertex in all graphs
@ -1998,6 +1999,7 @@ var bindVertexCollections = function(self, vertexCollections) {
collections: { collections: {
write: self.__collectionsToLock write: self.__collectionsToLock
}, },
embed: true,
action: function (params) { action: function (params) {
var db = require("internal").db; var db = require("internal").db;
params.ids.forEach( params.ids.forEach(
@ -2021,14 +2023,15 @@ var bindVertexCollections = function(self, vertexCollections) {
vertexId: vertexId vertexId: vertexId
} }
}); });
result = true;
} catch (e) { } catch (e) {
result = false; self.__idsToRemove = [];
self.__collectionsToLock = [];
throw e;
} }
self.__idsToRemove = []; self.__idsToRemove = [];
self.__collectionsToLock = []; self.__collectionsToLock = [];
return result; return true;
}; };
self[key] = wrap; self[key] = wrap;
}); });

View File

@ -1910,7 +1910,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
// remove // remove
wrap.remove = function(edgeId, options) { wrap.remove = function(edgeId, options) {
var result;
//if _key make _id (only on 1st call) //if _key make _id (only on 1st call)
if (edgeId.indexOf("/") === -1) { if (edgeId.indexOf("/") === -1) {
edgeId = key + "/" + edgeId; edgeId = key + "/" + edgeId;
@ -1922,6 +1921,7 @@ var bindEdgeCollections = function(self, edgeCollections) {
collections: { collections: {
write: self.__collectionsToLock write: self.__collectionsToLock
}, },
embed: true,
action: function (params) { action: function (params) {
var db = require("internal").db; var db = require("internal").db;
params.ids.forEach( params.ids.forEach(
@ -1939,13 +1939,15 @@ var bindEdgeCollections = function(self, edgeCollections) {
options: options options: options
} }
}); });
result = true;
} catch (e) { } catch (e) {
result = false; self.__idsToRemove = [];
self.__collectionsToLock = [];
throw e;
} }
self.__idsToRemove = []; self.__idsToRemove = [];
self.__collectionsToLock = []; self.__collectionsToLock = [];
return result;
return true;
}; };
self[key] = wrap; self[key] = wrap;
@ -1955,7 +1957,6 @@ var bindEdgeCollections = function(self, edgeCollections) {
var bindVertexCollections = function(self, vertexCollections) { var bindVertexCollections = function(self, vertexCollections) {
_.each(vertexCollections, function(key) { _.each(vertexCollections, function(key) {
var obj = db._collection(key); var obj = db._collection(key);
var result;
var wrap = wrapCollection(obj); var wrap = wrapCollection(obj);
wrap.remove = function(vertexId, options) { wrap.remove = function(vertexId, options) {
//delete all edges using the vertex in all graphs //delete all edges using the vertex in all graphs
@ -1997,6 +1998,7 @@ var bindVertexCollections = function(self, vertexCollections) {
collections: { collections: {
write: self.__collectionsToLock write: self.__collectionsToLock
}, },
embed: true,
action: function (params) { action: function (params) {
var db = require("internal").db; var db = require("internal").db;
params.ids.forEach( params.ids.forEach(
@ -2020,14 +2022,15 @@ var bindVertexCollections = function(self, vertexCollections) {
vertexId: vertexId vertexId: vertexId
} }
}); });
result = true;
} catch (e) { } catch (e) {
result = false; self.__idsToRemove = [];
self.__collectionsToLock = [];
throw e;
} }
self.__idsToRemove = []; self.__idsToRemove = [];
self.__collectionsToLock = []; self.__collectionsToLock = [];
return result; return true;
}; };
self[key] = wrap; self[key] = wrap;
}); });