From 303abcc60dfb47f852fb4c68817ff2cc62986dfc Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 11 Nov 2013 16:38:38 +0100 Subject: [PATCH 1/2] issue #665: Hash/skiplist combo madness bit my ass --- arangod/VocBase/document-collection.c | 1 + js/common/tests/shell-hash-index.js | 60 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/arangod/VocBase/document-collection.c b/arangod/VocBase/document-collection.c index be6b83e7c6..4dcff1d6d6 100644 --- a/arangod/VocBase/document-collection.c +++ b/arangod/VocBase/document-collection.c @@ -957,6 +957,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection, if (res != TRI_ERROR_NO_ERROR) { // insertion into secondary indexes failed DeletePrimaryIndex(document, header, true); + DeleteSecondaryIndexes(document, header, true); document->_headers->release(document->_headers, header, true); return res; diff --git a/js/common/tests/shell-hash-index.js b/js/common/tests/shell-hash-index.js index 6866096ee4..e2f3525ae5 100644 --- a/js/common/tests/shell-hash-index.js +++ b/js/common/tests/shell-hash-index.js @@ -235,6 +235,66 @@ function HashIndexSuite() { catch (err) { assertEqual(errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code, err.errorNum); } + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test: combination of indexes +//////////////////////////////////////////////////////////////////////////////// + + testMultiIndexViolation1 : function () { + collection.ensureUniqueConstraint("a"); + collection.ensureSkiplist("b"); + + collection.save({ a : "test1", b : 1}); + try { + collection.save({ a : "test1", b : 1}); + fail(); + } + catch (err1) { + } + + var doc1 = collection.save({ a : "test2", b : 1}); + assertTrue(doc1._key !== ""); + + try { + collection.save({ a : "test1", b : 1}); + fail(); + } + catch (err2) { + } + + var doc2 = collection.save({ a : "test3", b : 1}); + assertTrue(doc2._key !== ""); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test: combination of indexes +//////////////////////////////////////////////////////////////////////////////// + + testMultiIndexViolation2 : function () { + collection.ensureUniqueSkiplist("a"); + collection.ensureHashIndex("b"); + + collection.save({ a : "test1", b : 1}); + try { + collection.save({ a : "test1", b : 1}); + fail(); + } + catch (err1) { + } + + var doc1 = collection.save({ a : "test2", b : 1}); + assertTrue(doc1._key !== ""); + + try { + collection.save({ a : "test1", b : 1}); + fail(); + } + catch (err2) { + } + + var doc2 = collection.save({ a : "test3", b : 1}); + assertTrue(doc2._key !== ""); } }; From 40894ad2587f89eae096813c41b6eeb59e065cc3 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 11 Nov 2013 16:39:11 +0100 Subject: [PATCH 2/2] removed unused definition --- arangod/VocBase/vocbase.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arangod/VocBase/vocbase.h b/arangod/VocBase/vocbase.h index 80891bd2ff..c0d89e51ea 100644 --- a/arangod/VocBase/vocbase.h +++ b/arangod/VocBase/vocbase.h @@ -149,13 +149,6 @@ struct TRI_vocbase_defaults_s; #define TRI_WAIT_SYNCHRONISER_WAITER_VOCBASE(a, b) \ TRI_TimedWaitCondition(&(a)->_syncWaitersCondition, (b)) -//////////////////////////////////////////////////////////////////////////////// -/// @brief signals the synchroniser waiters -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_BROADCAST_SYNCHRONISER_WAITER_VOCBASE(a) \ - TRI_BroadcastCondition(&(a)->_syncWaitersCondition) - //////////////////////////////////////////////////////////////////////////////// /// @brief reduces the number of sync waiters ////////////////////////////////////////////////////////////////////////////////