1
0
Fork 0

added transaction to all signatures

This commit is contained in:
Jan Steemann 2015-11-24 17:34:23 +01:00
parent 5518244942
commit 75e4e6e815
36 changed files with 493 additions and 672 deletions

View File

@ -112,9 +112,6 @@ void QueryRegistry::insert (QueryId id,
TRI_ASSERT_EXPENSIVE(_queries.find(vocbase->_name)->second.find(id) != _queries.find(vocbase->_name)->second.end());
// Also, we need to count down the debugging counters for transactions:
triagens::arango::TransactionBase::increaseNumbers(-1, -1);
// If we have set _makeNolockHeaders, we need to unset it:
if (Transaction::_makeNolockHeaders != nullptr) {
if (Transaction::_makeNolockHeaders == query->engine()->lockedShards()) {
@ -157,9 +154,6 @@ Query* QueryRegistry::open (TRI_vocbase_t* vocbase,
}
qi->_isOpen = true;
// We need to count up the debugging counters for transactions:
triagens::arango::TransactionBase::increaseNumbers(1, 1);
// If we had set _makeNolockHeaders, we need to reset it:
if (qi->_query->engine()->lockedShards() != nullptr) {
if (Transaction::_makeNolockHeaders == nullptr) {
@ -198,9 +192,6 @@ void QueryRegistry::close (TRI_vocbase_t* vocbase, QueryId id, double ttl) {
"query with given vocbase and id is not open");
}
// We need to count down the debugging counters for transactions:
triagens::arango::TransactionBase::increaseNumbers(-1, -1);
// If we have set _makeNolockHeaders, we need to unset it:
if (Transaction::_makeNolockHeaders != nullptr) {
if (Transaction::_makeNolockHeaders == qi->_query->engine()->lockedShards()) {
@ -248,8 +239,6 @@ void QueryRegistry::destroy (std::string const& vocbase,
// to register the transaction with the current context and adjust
// the debugging counters for transactions:
if (! qi->_isOpen) {
// We need to count up the debugging counters for transactions:
triagens::arango::TransactionBase::increaseNumbers(1, 1);
// If we had set _makeNolockHeaders, we need to reset it:
if (qi->_query->engine()->lockedShards() != nullptr) {
if (Transaction::_makeNolockHeaders == nullptr) {

View File

@ -55,8 +55,6 @@ CapConstraint::CapConstraint (TRI_idx_iid_t iid,
: Index(iid, collection, std::vector<std::vector<triagens::basics::AttributeName>>(), false, false),
_count(count),
_size(static_cast<int64_t>(size)) {
initialize();
}
CapConstraint::~CapConstraint () {
@ -96,7 +94,8 @@ triagens::basics::Json CapConstraint::toJsonFigures (TRI_memory_zone_t* zone) co
return json;
}
int CapConstraint::insert (TRI_doc_mptr_t const* doc,
int CapConstraint::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
if (_size > 0) {
// there is a size restriction
@ -111,27 +110,25 @@ int CapConstraint::insert (TRI_doc_mptr_t const* doc,
return TRI_ERROR_NO_ERROR;
}
int CapConstraint::remove (TRI_doc_mptr_t const*,
int CapConstraint::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const*,
bool) {
return TRI_ERROR_NO_ERROR;
}
int CapConstraint::postInsert (TRI_transaction_collection_t* trxCollection,
int CapConstraint::postInsert (triagens::arango::Transaction* trx,
TRI_transaction_collection_t* trxCollection,
TRI_doc_mptr_t const*) {
TRI_ASSERT(_count > 0 || _size > 0);
return apply(trxCollection->_collection->_collection, trxCollection);
return apply(trx, trxCollection->_collection->_collection, trxCollection);
}
// -----------------------------------------------------------------------------
// --SECTION-- private methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief initialize the cap constraint
////////////////////////////////////////////////////////////////////////////////
int CapConstraint::initialize () {
int CapConstraint::initialize (triagens::arango::Transaction* trx) {
TRI_ASSERT(_count > 0 || _size > 0);
TRI_headers_t* headers = _collection->_headersPtr; // ONLY IN INDEX (CAP)
@ -160,7 +157,7 @@ int CapConstraint::initialize () {
}
TRI_transaction_collection_t* trxCollection = trx.trxCollection();
res = apply(_collection, trxCollection);
res = apply(&trx, _collection, trxCollection);
res = trx.finish(res);
@ -168,11 +165,16 @@ int CapConstraint::initialize () {
}
}
// -----------------------------------------------------------------------------
// --SECTION-- private methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief apply the cap constraint for the collection
////////////////////////////////////////////////////////////////////////////////
int CapConstraint::apply (TRI_document_collection_t* document,
int CapConstraint::apply (triagens::arango::Transaction* trx,
TRI_document_collection_t* document,
TRI_transaction_collection_t* trxCollection) {
TRI_headers_t* headers = document->_headersPtr; // PROTECTED by trx in trxCollection
int64_t currentCount = static_cast<int64_t>(headers->count());
@ -192,7 +194,7 @@ int CapConstraint::apply (TRI_document_collection_t* document,
TRI_ASSERT(oldSize > 0);
if (trxCollection != nullptr) {
res = TRI_DeleteDocumentDocumentCollection(trxCollection, nullptr, oldest);
res = TRI_DeleteDocumentDocumentCollection(trx, trxCollection, nullptr, oldest);
if (res != TRI_ERROR_NO_ERROR) {
LOG_WARNING("cannot cap collection: %s", TRI_errno_string(res));

View File

@ -102,11 +102,17 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (struct TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int remove (struct TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int postInsert (struct TRI_transaction_collection_s*, struct TRI_doc_mptr_t const*) override final;
int postInsert (triagens::arango::Transaction*, struct TRI_transaction_collection_s*, struct TRI_doc_mptr_t const*) override final;
////////////////////////////////////////////////////////////////////////////////
/// @brief initialize the cap constraint
////////////////////////////////////////////////////////////////////////////////
int initialize (triagens::arango::Transaction*);
// -----------------------------------------------------------------------------
// --SECTION-- private methods
@ -114,17 +120,12 @@ namespace triagens {
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief initialize the cap constraint
////////////////////////////////////////////////////////////////////////////////
int initialize ();
////////////////////////////////////////////////////////////////////////////////
/// @brief apply the cap constraint for the collection
////////////////////////////////////////////////////////////////////////////////
int apply (TRI_document_collection_t*,
int apply (triagens::arango::Transaction*,
TRI_document_collection_t*,
struct TRI_transaction_collection_s*);
// -----------------------------------------------------------------------------

View File

@ -76,7 +76,7 @@ static uint64_t HashElementEdgeFrom (void const* data,
}
else {
TRI_doc_mptr_t const* mptr = static_cast<TRI_doc_mptr_t const*>(data);
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* edge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -116,7 +116,7 @@ static uint64_t HashElementEdgeTo (void const* data,
}
else {
TRI_doc_mptr_t const* mptr = static_cast<TRI_doc_mptr_t const*>(data);
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* edge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -156,7 +156,7 @@ static bool IsEqualKeyEdgeFrom (void const* left,
char const* lKey = l->_key;
TRI_doc_mptr_t const* rMptr = static_cast<TRI_doc_mptr_t const*>(right);
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* rEdge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -192,7 +192,7 @@ static bool IsEqualKeyEdgeTo (void const* left,
char const* lKey = l->_key;
TRI_doc_mptr_t const* rMptr = static_cast<TRI_doc_mptr_t const*>(right);
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* rEdge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -240,7 +240,7 @@ static bool IsEqualElementEdgeFromByKey (void const* left,
// left element
TRI_doc_mptr_t const* lMptr = static_cast<TRI_doc_mptr_t const*>(left);
marker = static_cast<TRI_df_marker_t const*>(lMptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
marker = static_cast<TRI_df_marker_t const*>(lMptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* lEdge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -255,7 +255,7 @@ static bool IsEqualElementEdgeFromByKey (void const* left,
// right element
TRI_doc_mptr_t const* rMptr = static_cast<TRI_doc_mptr_t const*>(right);
marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* rEdge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -294,7 +294,7 @@ static bool IsEqualElementEdgeToByKey (void const* left,
// left element
TRI_doc_mptr_t const* lMptr = static_cast<TRI_doc_mptr_t const*>(left);
marker = static_cast<TRI_df_marker_t const*>(lMptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
marker = static_cast<TRI_df_marker_t const*>(lMptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* lEdge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -309,7 +309,7 @@ static bool IsEqualElementEdgeToByKey (void const* left,
// right element
TRI_doc_mptr_t const* rMptr = static_cast<TRI_doc_mptr_t const*>(right);
marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtrUnchecked()); // ONLY IN INDEX, PROTECTED by RUNTIME
marker = static_cast<TRI_df_marker_t const*>(rMptr->getDataPtr()); // ONLY IN INDEX, PROTECTED by RUNTIME
if (marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
TRI_doc_edge_key_marker_t const* rEdge = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -506,7 +506,8 @@ triagens::basics::Json EdgeIndex::toJsonFigures (TRI_memory_zone_t* zone) const
return json;
}
int EdgeIndex::insert (TRI_doc_mptr_t const* doc,
int EdgeIndex::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool isRollback) {
auto element = const_cast<TRI_doc_mptr_t*>(doc);
_edgesFrom->insert(element, true, isRollback);
@ -522,7 +523,8 @@ int EdgeIndex::insert (TRI_doc_mptr_t const* doc,
return TRI_ERROR_NO_ERROR;
}
int EdgeIndex::remove (TRI_doc_mptr_t const* doc,
int EdgeIndex::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
_edgesFrom->remove(doc);
_edgesTo->remove(doc);
@ -530,7 +532,8 @@ int EdgeIndex::remove (TRI_doc_mptr_t const* doc,
return TRI_ERROR_NO_ERROR;
}
int EdgeIndex::batchInsert (std::vector<TRI_doc_mptr_t const*> const* documents,
int EdgeIndex::batchInsert (triagens::arango::Transaction*,
std::vector<TRI_doc_mptr_t const*> const* documents,
size_t numThreads) {
_edgesFrom->batchInsert(reinterpret_cast<std::vector<TRI_doc_mptr_t *> const*>(documents), numThreads);
_edgesTo->batchInsert(reinterpret_cast<std::vector<TRI_doc_mptr_t *> const*>(documents), numThreads);

View File

@ -147,11 +147,12 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (struct TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int remove (struct TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int batchInsert (std::vector<TRI_doc_mptr_t const*> const*,
int batchInsert (triagens::arango::Transaction*,
std::vector<TRI_doc_mptr_t const*> const*,
size_t) override final;
////////////////////////////////////////////////////////////////////////////////

View File

@ -186,7 +186,8 @@ triagens::basics::Json FulltextIndex::toJsonFigures (TRI_memory_zone_t* zone) co
return json;
}
int FulltextIndex::insert (TRI_doc_mptr_t const* doc,
int FulltextIndex::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool isRollback) {
int res = TRI_ERROR_NO_ERROR;
@ -212,7 +213,8 @@ int FulltextIndex::insert (TRI_doc_mptr_t const* doc,
return res;
}
int FulltextIndex::remove (TRI_doc_mptr_t const* doc,
int FulltextIndex::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
TRI_DeleteDocumentFulltextIndex(_fulltextIndex, (TRI_fulltext_doc_t) ((uintptr_t) doc));

View File

@ -90,9 +90,9 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (struct TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int remove (struct TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int cleanup () override final;

View File

@ -181,7 +181,8 @@ triagens::basics::Json GeoIndex2::toJsonFigures (TRI_memory_zone_t* zone) const
return json;
}
int GeoIndex2::insert (TRI_doc_mptr_t const* doc,
int GeoIndex2::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
auto shaper = _collection->getShaper(); // ONLY IN INDEX, PROTECTED by RUNTIME
@ -236,7 +237,8 @@ int GeoIndex2::insert (TRI_doc_mptr_t const* doc,
return TRI_ERROR_NO_ERROR;
}
int GeoIndex2::remove (TRI_doc_mptr_t const* doc,
int GeoIndex2::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
TRI_shaped_json_t shapedJson;

View File

@ -118,9 +118,9 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (struct TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int remove (struct TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
////////////////////////////////////////////////////////////////////////////////
/// @brief looks up all points within a given radius

View File

@ -417,11 +417,13 @@ triagens::basics::Json HashIndex::toJsonFigures (TRI_memory_zone_t* zone) const
return json;
}
int HashIndex::insert (TRI_doc_mptr_t const* doc,
int HashIndex::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool isRollback) {
if (_unique) {
return insertUnique(doc, isRollback);
}
return insertMulti(doc, isRollback);
}
@ -429,22 +431,26 @@ int HashIndex::insert (TRI_doc_mptr_t const* doc,
/// @brief removes an entry from the hash array part of the hash index
////////////////////////////////////////////////////////////////////////////////
int HashIndex::remove (TRI_doc_mptr_t const* doc,
int HashIndex::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool isRollback) {
if (_unique) {
return removeUnique(doc, isRollback);
}
return removeMulti(doc, isRollback);
}
int HashIndex::batchInsert (std::vector<TRI_doc_mptr_t const*> const* documents,
int HashIndex::batchInsert (triagens::arango::Transaction* trx,
std::vector<TRI_doc_mptr_t const*> const* documents,
size_t numThreads) {
if (_unique) {
return batchInsertUnique(documents, numThreads);
return batchInsertUnique(trx, documents, numThreads);
}
return batchInsertMulti(documents, numThreads);
return batchInsertMulti(trx, documents, numThreads);
}
////////////////////////////////////////////////////////////////////////////////
@ -612,7 +618,8 @@ int HashIndex::insertUnique (TRI_doc_mptr_t const* doc,
return res;
}
int HashIndex::batchInsertUnique (std::vector<TRI_doc_mptr_t const*> const* documents,
int HashIndex::batchInsertUnique (triagens::arango::Transaction*,
std::vector<TRI_doc_mptr_t const*> const* documents,
size_t numThreads) {
std::vector<TRI_index_element_t*> elements;
elements.reserve(documents->size());
@ -704,7 +711,8 @@ int HashIndex::insertMulti (TRI_doc_mptr_t const* doc,
return TRI_ERROR_NO_ERROR;
}
int HashIndex::batchInsertMulti (std::vector<TRI_doc_mptr_t const*> const* documents,
int HashIndex::batchInsertMulti (triagens::arango::Transaction*,
std::vector<TRI_doc_mptr_t const*> const* documents,
size_t numThreads) {
std::vector<TRI_index_element_t*> elements;

View File

@ -149,11 +149,12 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (struct TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int remove (struct TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int batchInsert (std::vector<TRI_doc_mptr_t const*> const*,
int batchInsert (triagens::arango::Transaction*,
std::vector<TRI_doc_mptr_t const*> const*,
size_t) override final;
int sizeHint (size_t) override final;
@ -205,11 +206,11 @@ namespace triagens {
int insertUnique (struct TRI_doc_mptr_t const*, bool);
int batchInsertUnique (std::vector<TRI_doc_mptr_t const*> const*, size_t);
int batchInsertUnique (triagens::arango::Transaction*, std::vector<TRI_doc_mptr_t const*> const*, size_t);
int insertMulti (struct TRI_doc_mptr_t const*, bool);
int batchInsertMulti (std::vector<TRI_doc_mptr_t const*> const*, size_t);
int batchInsertMulti (triagens::arango::Transaction*, std::vector<TRI_doc_mptr_t const*> const*, size_t);
int removeUniqueElement (TRI_index_element_t*, bool);

View File

@ -451,7 +451,9 @@ double Index::selectivityEstimate () const {
/// @brief default implementation for selectivityEstimate
////////////////////////////////////////////////////////////////////////////////
int Index::batchInsert (std::vector<TRI_doc_mptr_t const*> const*, size_t) {
int Index::batchInsert (triagens::arango::Transaction*,
std::vector<TRI_doc_mptr_t const*> const*,
size_t) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
}
@ -459,7 +461,8 @@ int Index::batchInsert (std::vector<TRI_doc_mptr_t const*> const*, size_t) {
/// @brief default implementation for postInsert
////////////////////////////////////////////////////////////////////////////////
int Index::postInsert (struct TRI_transaction_collection_s*,
int Index::postInsert (triagens::arango::Transaction*,
struct TRI_transaction_collection_s*,
struct TRI_doc_mptr_t const*) {
// do nothing
return TRI_ERROR_NO_ERROR;

View File

@ -339,10 +339,10 @@ namespace triagens {
virtual triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const;
virtual bool dumpFields () const = 0;
virtual int insert (struct TRI_doc_mptr_t const*, bool) = 0;
virtual int remove (struct TRI_doc_mptr_t const*, bool) = 0;
virtual int postInsert (struct TRI_transaction_collection_s*, struct TRI_doc_mptr_t const*);
virtual int batchInsert (std::vector<TRI_doc_mptr_t const*> const*, size_t);
virtual int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) = 0;
virtual int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) = 0;
virtual int postInsert (triagens::arango::Transaction*, struct TRI_transaction_collection_s*, struct TRI_doc_mptr_t const*);
virtual int batchInsert (triagens::arango::Transaction*, std::vector<TRI_doc_mptr_t const*> const*, size_t);
// a garbage collection function for the index
virtual int cleanup ();

View File

@ -195,12 +195,14 @@ triagens::basics::Json PrimaryIndex::toJsonFigures (TRI_memory_zone_t* zone) con
return json;
}
int PrimaryIndex::insert (TRI_doc_mptr_t const*,
int PrimaryIndex::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const*,
bool) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
}
int PrimaryIndex::remove (TRI_doc_mptr_t const*,
int PrimaryIndex::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const*,
bool) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
}

View File

@ -137,9 +137,9 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, TRI_doc_mptr_t const*, bool) override final;
int remove (TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, TRI_doc_mptr_t const*, bool) override final;
TRI_doc_mptr_t* lookupKey (char const*) const;

View File

@ -859,7 +859,8 @@ triagens::basics::Json SkiplistIndex::toJsonFigures (TRI_memory_zone_t* zone) co
/// @brief inserts a document into a skiplist index
////////////////////////////////////////////////////////////////////////////////
int SkiplistIndex::insert (TRI_doc_mptr_t const* doc,
int SkiplistIndex::insert (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
std::vector<TRI_index_element_t*> elements;
@ -909,7 +910,8 @@ int SkiplistIndex::insert (TRI_doc_mptr_t const* doc,
/// @brief removes a document from a skiplist index
////////////////////////////////////////////////////////////////////////////////
int SkiplistIndex::remove (TRI_doc_mptr_t const* doc,
int SkiplistIndex::remove (triagens::arango::Transaction*,
TRI_doc_mptr_t const* doc,
bool) {
std::vector<TRI_index_element_t*> elements;
@ -990,8 +992,6 @@ int SkiplistIndex::KeyElementComparator::operator() (TRI_skiplist_index_key_t co
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief compares two elements in a skip list, this is the generic callback
////////////////////////////////////////////////////////////////////////////////

View File

@ -290,9 +290,9 @@ namespace triagens {
triagens::basics::Json toJson (TRI_memory_zone_t*, bool) const override final;
triagens::basics::Json toJsonFigures (TRI_memory_zone_t*) const override final;
int insert (struct TRI_doc_mptr_t const*, bool) override final;
int insert (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
int remove (struct TRI_doc_mptr_t const*, bool) override final;
int remove (triagens::arango::Transaction*, struct TRI_doc_mptr_t const*, bool) override final;
////////////////////////////////////////////////////////////////////////////////
/// @brief attempts to locate an entry in the skip list index

View File

@ -457,7 +457,8 @@ int ContinuousSyncer::processDocument (TRI_replication_operation_e type,
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
}
int res = applyCollectionDumpMarker(trxCollection,
int res = applyCollectionDumpMarker(trx,
trxCollection,
type,
(const TRI_voc_key_t) keyJson->_value._string.data,
rid,
@ -491,7 +492,8 @@ int ContinuousSyncer::processDocument (TRI_replication_operation_e type,
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
}
res = applyCollectionDumpMarker(trxCollection,
res = applyCollectionDumpMarker(&trx,
trxCollection,
type,
(const TRI_voc_key_t) keyJson->_value._string.data,
rid,

View File

@ -469,7 +469,8 @@ int InitialSyncer::sendFinishBatch () {
/// @brief apply the data from a collection dump
////////////////////////////////////////////////////////////////////////////////
int InitialSyncer::applyCollectionDump (TRI_transaction_collection_t* trxCollection,
int InitialSyncer::applyCollectionDump (triagens::arango::Transaction* trx,
TRI_transaction_collection_t* trxCollection,
SimpleHttpResult* response,
uint64_t& markersProcessed,
string& errorMsg) {
@ -562,7 +563,7 @@ int InitialSyncer::applyCollectionDump (TRI_transaction_collection_t* trxCollect
}
++markersProcessed;
int res = applyCollectionDumpMarker(trxCollection, type, (const TRI_voc_key_t) key, rid, doc, errorMsg);
int res = applyCollectionDumpMarker(trx, trxCollection, type, (const TRI_voc_key_t) key, rid, doc, errorMsg);
if (res != TRI_ERROR_NO_ERROR) {
return res;
@ -577,7 +578,8 @@ int InitialSyncer::applyCollectionDump (TRI_transaction_collection_t* trxCollect
/// @brief incrementally fetch data from a collection
////////////////////////////////////////////////////////////////////////////////
int InitialSyncer::handleCollectionDump (string const& cid,
int InitialSyncer::handleCollectionDump (triagens::arango::Transaction* trx,
string const& cid,
TRI_transaction_collection_t* trxCollection,
string const& collectionName,
TRI_voc_tick_t maxTick,
@ -686,7 +688,7 @@ int InitialSyncer::handleCollectionDump (string const& cid,
}
if (res == TRI_ERROR_NO_ERROR) {
res = applyCollectionDump(trxCollection, response.get(), markersProcessed, errorMsg);
res = applyCollectionDump(trx, trxCollection, response.get(), markersProcessed, errorMsg);
}
if (res != TRI_ERROR_NO_ERROR) {
@ -943,7 +945,7 @@ int InitialSyncer::handleSyncKeys (std::string const& keysId,
break;
}
TRI_RemoveShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) key, 0, nullptr, &policy, false, false);
TRI_RemoveShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) key, 0, nullptr, &policy, false, false);
}
// last high
@ -960,7 +962,7 @@ int InitialSyncer::handleSyncKeys (std::string const& keysId,
break;
}
TRI_RemoveShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) key, 0, nullptr, &policy, false, false);
TRI_RemoveShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) key, 0, nullptr, &policy, false, false);
}
}
@ -1074,7 +1076,7 @@ int InitialSyncer::handleSyncKeys (std::string const& keysId,
if (res < 0) {
// we have a local key that is not present remotely
TRI_RemoveShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) localKey, 0, nullptr, &policy, false, false);
TRI_RemoveShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) localKey, 0, nullptr, &policy, false, false);
++nextStart;
}
else {
@ -1119,7 +1121,7 @@ int InitialSyncer::handleSyncKeys (std::string const& keysId,
if (res < 0) {
// we have a local key that is not present remotely
TRI_RemoveShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) localKey, 0, nullptr, &policy, false, false);
TRI_RemoveShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) localKey, 0, nullptr, &policy, false, false);
++nextStart;
}
else if (res >= 0) {
@ -1289,15 +1291,15 @@ int InitialSyncer::handleSyncKeys (std::string const& keysId,
if (res == TRI_ERROR_NO_ERROR) {
if (mptr != nullptr && isEdge) {
// must remove existing edge first
TRI_RemoveShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) documentKey.c_str(), 0, nullptr, &policy, false, false);
TRI_RemoveShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) documentKey.c_str(), 0, nullptr, &policy, false, false);
}
res = TRI_InsertShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) documentKey.c_str(), rid, nullptr, &result, shaped, e, false, false, true);
res = TRI_InsertShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) documentKey.c_str(), rid, nullptr, &result, shaped, e, false, false, true);
}
}
else {
// UPDATE
res = TRI_UpdateShapedJsonDocumentCollection(trx.trxCollection(), (TRI_voc_key_t) documentKey.c_str(), rid, nullptr, &result, shaped, &policy, false, false);
res = TRI_UpdateShapedJsonDocumentCollection(&trx, trx.trxCollection(), (TRI_voc_key_t) documentKey.c_str(), rid, nullptr, &result, shaped, &policy, false, false);
}
TRI_FreeShapedJson(shaper->memoryZone(), shaped);
@ -1543,13 +1545,10 @@ int InitialSyncer::handleCollection (TRI_json_t const* parameters,
res = handleCollectionSync(StringUtils::itoa(cid), trx, masterName, _masterInfo._lastLogTick, errorMsg);
}
else {
res = handleCollectionDump(StringUtils::itoa(cid), trxCollection, masterName, _masterInfo._lastLogTick, errorMsg);
res = handleCollectionDump(&trx, StringUtils::itoa(cid), trxCollection, masterName, _masterInfo._lastLogTick, errorMsg);
}
}
res = trx.finish(res);
}
if (res == TRI_ERROR_NO_ERROR) {
// now create indexes
size_t const n = TRI_LengthVector(&indexes->_value._objects);
@ -1571,8 +1570,6 @@ int InitialSyncer::handleCollection (TRI_json_t const* parameters,
TRI_document_collection_t* document = col->_collection;
TRI_ASSERT(document != nullptr);
// create a fake transaction object to avoid assertions
TransactionBase trx(true);
TRI_WRITE_LOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(document);
for (size_t i = 0; i < n; ++i) {
@ -1581,7 +1578,7 @@ int InitialSyncer::handleCollection (TRI_json_t const* parameters,
// {"id":"229907440927234","type":"hash","unique":false,"fields":["x","Y"]}
res = TRI_FromJsonIndexDocumentCollection(document, idxDef, &idx);
res = TRI_FromJsonIndexDocumentCollection(&trx, document, idxDef, &idx);
if (res != TRI_ERROR_NO_ERROR) {
errorMsg = "could not create index: " + string(TRI_errno_string(res));
@ -1612,6 +1609,10 @@ int InitialSyncer::handleCollection (TRI_json_t const* parameters,
}
}
res = trx.finish(res);
}
return res;
}

View File

@ -195,7 +195,8 @@ namespace triagens {
/// @brief apply the data from a collection dump
////////////////////////////////////////////////////////////////////////////////
int applyCollectionDump (struct TRI_transaction_collection_s*,
int applyCollectionDump (triagens::arango::Transaction*,
struct TRI_transaction_collection_s*,
httpclient::SimpleHttpResult*,
uint64_t&,
std::string&);
@ -205,7 +206,8 @@ namespace triagens {
/// @brief incrementally fetch data from a collection
////////////////////////////////////////////////////////////////////////////////
int handleCollectionDump (std::string const&,
int handleCollectionDump (triagens::arango::Transaction*,
std::string const&,
struct TRI_transaction_collection_s*,
std::string const&,
TRI_voc_tick_t,

View File

@ -203,7 +203,8 @@ TRI_voc_cid_t Syncer::getCid (TRI_json_t const* json) const {
/// @brief apply the data from a collection dump or the continuous log
////////////////////////////////////////////////////////////////////////////////
int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollection,
int Syncer::applyCollectionDumpMarker (triagens::arango::Transaction* trx,
TRI_transaction_collection_t* trxCollection,
TRI_replication_operation_e type,
const TRI_voc_key_t key,
const TRI_voc_rid_t rid,
@ -230,7 +231,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
TRI_doc_mptr_copy_t mptr;
bool const isLocked = TRI_IsLockedCollectionTransaction(trxCollection);
int res = TRI_ReadShapedJsonDocumentCollection(trxCollection, key, &mptr, ! isLocked);
int res = TRI_ReadShapedJsonDocumentCollection(trx, trxCollection, key, &mptr, ! isLocked);
if (res == TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND) {
// insert
@ -261,7 +262,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
}
if (res == TRI_ERROR_NO_ERROR) {
res = TRI_InsertShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &mptr, shaped, &edge, ! isLocked, false, true);
res = TRI_InsertShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &mptr, shaped, &edge, ! isLocked, false, true);
}
}
else {
@ -270,13 +271,13 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID;
}
else {
res = TRI_InsertShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &mptr, shaped, nullptr, ! isLocked, false, true);
res = TRI_InsertShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &mptr, shaped, nullptr, ! isLocked, false, true);
}
}
}
else {
// update
res = TRI_UpdateShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &mptr, shaped, &_policy, ! isLocked, false);
res = TRI_UpdateShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &mptr, shaped, &_policy, ! isLocked, false);
}
TRI_FreeShapedJson(zone, shaped);
@ -300,7 +301,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
bool const isLocked = TRI_IsLockedCollectionTransaction(trxCollection);
try {
res = TRI_RemoveShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &_policy, ! isLocked, false);
res = TRI_RemoveShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &_policy, ! isLocked, false);
if (res != TRI_ERROR_NO_ERROR && res == TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND) {
// ignore this error
@ -486,7 +487,7 @@ int Syncer::createIndex (TRI_json_t const* json) {
}
triagens::arango::Index* idx = nullptr;
res = TRI_FromJsonIndexDocumentCollection(document, indexJson, &idx);
res = TRI_FromJsonIndexDocumentCollection(&trx, document, indexJson, &idx);
if (res == TRI_ERROR_NO_ERROR) {
res = TRI_SaveIndex(document, idx, true);

View File

@ -61,6 +61,7 @@ namespace triagens {
}
namespace arango {
class Transaction;
// -----------------------------------------------------------------------------
// --SECTION-- Syncer
@ -113,7 +114,8 @@ namespace triagens {
/// @brief apply a single marker from the collection dump
////////////////////////////////////////////////////////////////////////////////
int applyCollectionDumpMarker (struct TRI_transaction_collection_s*,
int applyCollectionDumpMarker (triagens::arango::Transaction*,
struct TRI_transaction_collection_s*,
TRI_replication_operation_e,
const TRI_voc_key_t,
const TRI_voc_rid_t,

View File

@ -2326,7 +2326,7 @@ int RestReplicationHandler::processRestoreIndexes (TRI_json_t const* collection,
// {"id":"229907440927234","type":"hash","unique":false,"fields":["x","Y"]}
res = TRI_FromJsonIndexDocumentCollection(document, idxDef, &idx);
res = TRI_FromJsonIndexDocumentCollection(&trx, document, idxDef, &idx);
if (res != TRI_ERROR_NO_ERROR) {
errorMsg = "could not create index: " + string(TRI_errno_string(res));
@ -2438,7 +2438,8 @@ int RestReplicationHandler::processRestoreIndexesCoordinator (
/// @brief apply the data from a collection dump or the continuous log
////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver const& resolver,
int RestReplicationHandler::applyCollectionDumpMarker (triagens::arango::Transaction* trx,
CollectionNameResolver const& resolver,
TRI_transaction_collection_t* trxCollection,
TRI_replication_operation_e type,
const TRI_voc_key_t key,
@ -2465,7 +2466,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
try {
TRI_doc_mptr_copy_t mptr;
int res = TRI_ReadShapedJsonDocumentCollection(trxCollection, key, &mptr, false);
int res = TRI_ReadShapedJsonDocumentCollection(trx, trxCollection, key, &mptr, false);
if (res == TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND) {
// insert
@ -2494,7 +2495,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
}
if (res == TRI_ERROR_NO_ERROR) {
res = TRI_InsertShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &mptr, shaped, &edge, false, false, true);
res = TRI_InsertShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &mptr, shaped, &edge, false, false, true);
}
}
}
@ -2504,7 +2505,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID;
}
else {
res = TRI_InsertShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &mptr, shaped, nullptr, false, false, true);
res = TRI_InsertShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &mptr, shaped, nullptr, false, false, true);
}
}
}
@ -2513,7 +2514,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
// init the update policy
TRI_doc_update_policy_t policy(TRI_DOC_UPDATE_LAST_WRITE, 0, nullptr);
res = TRI_UpdateShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &mptr, shaped, &policy, false, false);
res = TRI_UpdateShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &mptr, shaped, &policy, false, false);
}
TRI_FreeShapedJson(zone, shaped);
@ -2538,7 +2539,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
int res = TRI_ERROR_INTERNAL;
try {
res = TRI_RemoveShapedJsonDocumentCollection(trxCollection, key, rid, nullptr, &policy, false, false);
res = TRI_RemoveShapedJsonDocumentCollection(trx, trxCollection, key, rid, nullptr, &policy, false, false);
if (res != TRI_ERROR_NO_ERROR && res == TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND) {
// ignore this error
@ -2570,7 +2571,8 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
/// @brief restores the data of a collection TODO MOVE
////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreDataBatch (CollectionNameResolver const& resolver,
int RestReplicationHandler::processRestoreDataBatch (triagens::arango::Transaction* trx,
CollectionNameResolver const& resolver,
TRI_transaction_collection_t* trxCollection,
bool useRevision,
bool force,
@ -2658,7 +2660,7 @@ int RestReplicationHandler::processRestoreDataBatch (CollectionNameResolver cons
return TRI_ERROR_HTTP_BAD_PARAMETER;
}
int res = applyCollectionDumpMarker(resolver, trxCollection, type, (const TRI_voc_key_t) key, rid, doc, errorMsg);
int res = applyCollectionDumpMarker(trx, resolver, trxCollection, type, (const TRI_voc_key_t) key, rid, doc, errorMsg);
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
@ -2705,7 +2707,7 @@ int RestReplicationHandler::processRestoreData (CollectionNameResolver const& re
trxCollection->_waitForSync = false;
// create a fake transaction to avoid assertion failures. TODO: use proper transaction here
res = processRestoreDataBatch(resolver, trxCollection, useRevision, force, errorMsg);
res = processRestoreDataBatch(&trx, resolver, trxCollection, useRevision, force, errorMsg);
}
res = trx.finish(res);

View File

@ -49,6 +49,7 @@ struct TRI_vocbase_col_s;
namespace triagens {
namespace arango {
class Transaction;
////////////////////////////////////////////////////////////////////////////////
/// @brief replication request handler
@ -258,7 +259,8 @@ namespace triagens {
/// @brief apply a single marker from the collection dump
////////////////////////////////////////////////////////////////////////////////
int applyCollectionDumpMarker (CollectionNameResolver const&,
int applyCollectionDumpMarker (triagens::arango::Transaction*,
CollectionNameResolver const&,
struct TRI_transaction_collection_s*,
TRI_replication_operation_e,
const TRI_voc_key_t,
@ -270,7 +272,8 @@ namespace triagens {
/// @brief restores the data of a collection TODO MOVE
////////////////////////////////////////////////////////////////////////////////
int processRestoreDataBatch (CollectionNameResolver const&,
int processRestoreDataBatch (triagens::arango::Transaction*,
CollectionNameResolver const&,
struct TRI_transaction_collection_s*,
bool,
bool,

View File

@ -32,25 +32,6 @@
using namespace triagens::arango;
////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in scope in the current thread
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_ENABLE_MAINTAINER_MODE
thread_local int TransactionBase::_numberTrxInScope = 0;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in the current thread that are active (between
/// begin and commit()/abort().
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_ENABLE_MAINTAINER_MODE
thread_local int TransactionBase::_numberTrxActive = 0;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief if this pointer is set to an actual set, then for each request
/// sent to a shardId using the ClusterComm library, an X-Arango-Nolock

View File

@ -63,7 +63,7 @@ namespace triagens {
// --SECTION-- class Transaction
// -----------------------------------------------------------------------------
class Transaction : public TransactionBase {
class Transaction {
////////////////////////////////////////////////////////////////////////////////
/// @brief Transaction
@ -299,11 +299,6 @@ namespace triagens {
return _setupState;
}
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxActive == _numberTrxInScope - 1);
_numberTrxActive++; // Every transaction gets here at most once
#endif
if (! _isReal) {
if (_nestingLevel == 0) {
_trx->_status = TRI_TRANSACTION_RUNNING;
@ -331,22 +326,11 @@ namespace triagens {
if (_nestingLevel == 0) {
_trx->_status = TRI_TRANSACTION_COMMITTED;
}
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxActive == _numberTrxInScope);
TRI_ASSERT(_numberTrxActive > 0);
_numberTrxActive--; // Every transaction gets here at most once
#endif
return TRI_ERROR_NO_ERROR;
}
int res = TRI_CommitTransaction(_trx, _nestingLevel);
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxActive == _numberTrxInScope);
TRI_ASSERT(_numberTrxActive > 0);
_numberTrxActive--; // Every transaction gets here at most once
#endif
return res;
}
@ -365,22 +349,11 @@ namespace triagens {
_trx->_status = TRI_TRANSACTION_ABORTED;
}
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxActive == _numberTrxInScope);
TRI_ASSERT(_numberTrxActive > 0);
_numberTrxActive--; // Every transaction gets here at most once
#endif
return TRI_ERROR_NO_ERROR;
}
int res = TRI_AbortTransaction(_trx, _nestingLevel);
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxActive == _numberTrxInScope);
TRI_ASSERT(_numberTrxActive > 0);
_numberTrxActive--; // Every transaction gets here at most once
#endif
return res;
}
@ -485,7 +458,8 @@ namespace triagens {
TRI_doc_update_policy_t updatePolicy(policy, expectedRevision, actualRevision);
try {
return TRI_RemoveShapedJsonDocumentCollection(trxCollection,
return TRI_RemoveShapedJsonDocumentCollection(this,
trxCollection,
(TRI_voc_key_t) key.c_str(),
rid,
nullptr,
@ -594,7 +568,8 @@ namespace triagens {
}
try {
return TRI_ReadShapedJsonDocumentCollection(trxCollection,
return TRI_ReadShapedJsonDocumentCollection(this,
trxCollection,
(TRI_voc_key_t) key.c_str(),
mptr,
! isLocked(trxCollection, TRI_TRANSACTION_READ));
@ -893,7 +868,8 @@ namespace triagens {
bool lock = ! isLocked(trxCollection, TRI_TRANSACTION_WRITE);
try {
return TRI_InsertShapedJsonDocumentCollection(trxCollection,
return TRI_InsertShapedJsonDocumentCollection(this,
trxCollection,
key,
rid,
nullptr,
@ -933,7 +909,8 @@ namespace triagens {
}
try {
return TRI_UpdateShapedJsonDocumentCollection(trxCollection,
return TRI_UpdateShapedJsonDocumentCollection(this,
trxCollection,
(const TRI_voc_key_t) key.c_str(),
rid,
nullptr,
@ -975,7 +952,8 @@ namespace triagens {
try {
for (auto const& it : ids) {
res = TRI_RemoveShapedJsonDocumentCollection(trxCollection,
res = TRI_RemoveShapedJsonDocumentCollection(this,
trxCollection,
(TRI_voc_key_t) it.c_str(),
0,
nullptr, // marker

View File

@ -113,9 +113,6 @@ class MultiCollectionEdgeExpander {
void operator() (VertexId& source,
vector<ArangoDBPathFinder::Step*>& result) {
TransactionBase fake(true); // Fake a transaction to please checks.
// This is due to multi-threading
equal_to<VertexId> eq;
for (auto const& edgeCollection : _edgeCollections) {
auto edges = edgeCollection->getEdges(_direction, source);
@ -182,8 +179,6 @@ class SimpleEdgeExpander {
void operator() (VertexId& source,
vector<ArangoDBPathFinder::Step*>& result) {
TransactionBase fake(true); // Fake a transaction to please checks.
// This is due to multi-threading
auto edges = _edgeCollection->getEdges(_direction, source);
equal_to<VertexId> eq;

View File

@ -662,7 +662,8 @@ static void EnsureIndexLocal (const v8::FunctionCallbackInfo<v8::Value>& args,
}
if (create) {
idx = static_cast<triagens::arango::GeoIndex2*>(TRI_EnsureGeoIndex1DocumentCollection(document,
idx = static_cast<triagens::arango::GeoIndex2*>(TRI_EnsureGeoIndex1DocumentCollection(&trx,
document,
iid,
attributes[0],
geoJson,
@ -682,7 +683,8 @@ static void EnsureIndexLocal (const v8::FunctionCallbackInfo<v8::Value>& args,
}
if (create) {
idx = static_cast<triagens::arango::GeoIndex2*>(TRI_EnsureGeoIndex2DocumentCollection(document,
idx = static_cast<triagens::arango::GeoIndex2*>(TRI_EnsureGeoIndex2DocumentCollection(&trx,
document,
iid,
attributes[0],
attributes[1],
@ -702,7 +704,8 @@ static void EnsureIndexLocal (const v8::FunctionCallbackInfo<v8::Value>& args,
}
if (create) {
idx = static_cast<triagens::arango::HashIndex*>(TRI_EnsureHashIndexDocumentCollection(document,
idx = static_cast<triagens::arango::HashIndex*>(TRI_EnsureHashIndexDocumentCollection(&trx,
document,
iid,
attributes,
sparse,
@ -725,7 +728,8 @@ static void EnsureIndexLocal (const v8::FunctionCallbackInfo<v8::Value>& args,
}
if (create) {
idx = static_cast<triagens::arango::SkiplistIndex*>(TRI_EnsureSkiplistIndexDocumentCollection(document,
idx = static_cast<triagens::arango::SkiplistIndex*>(TRI_EnsureSkiplistIndexDocumentCollection(&trx,
document,
iid,
attributes,
sparse,
@ -757,7 +761,8 @@ static void EnsureIndexLocal (const v8::FunctionCallbackInfo<v8::Value>& args,
}
if (create) {
idx = static_cast<triagens::arango::FulltextIndex*>(TRI_EnsureFulltextIndexDocumentCollection(document,
idx = static_cast<triagens::arango::FulltextIndex*>(TRI_EnsureFulltextIndexDocumentCollection(&trx,
document,
iid,
attributes[0],
minWordLength,
@ -785,7 +790,8 @@ static void EnsureIndexLocal (const v8::FunctionCallbackInfo<v8::Value>& args,
}
if (create) {
idx = static_cast<triagens::arango::Index*>(TRI_EnsureCapConstraintDocumentCollection(document,
idx = static_cast<triagens::arango::Index*>(TRI_EnsureCapConstraintDocumentCollection(&trx,
document,
iid,
size,
byteSize,

View File

@ -769,10 +769,6 @@ static void CompactifyDatafiles (TRI_document_collection_t* document,
size_t const n = TRI_LengthVector(compactions);
TRI_ASSERT(n > 0);
// create a fake transaction
triagens::arango::TransactionBase trx(true);
initial = InitCompaction(document, compactions);
if (initial._failed) {

File diff suppressed because it is too large Load Diff

View File

@ -174,35 +174,17 @@ struct TRI_doc_mptr_t {
/// @brief return a pointer to the beginning of the marker
////////////////////////////////////////////////////////////////////////////////
#ifndef TRI_ENABLE_MAINTAINER_MODE
inline void const* getDataPtr () const {
return _dataptr;
}
#else
// The actual code has an assertion about transactions!
virtual void const* getDataPtr () const;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief return a pointer to the beginning of the marker, without checking
////////////////////////////////////////////////////////////////////////////////
inline void const* getDataPtrUnchecked () const {
return _dataptr;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief set the pointer to the beginning of the memory for the marker
////////////////////////////////////////////////////////////////////////////////
#ifndef TRI_ENABLE_MAINTAINER_MODE
inline void setDataPtr (void const* d) {
_dataptr = d;
}
#else
// The actual code has an assertion about transactions!
virtual void setDataPtr (void const* d);
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief return a pointer to the beginning of the shaped json stored in the
@ -259,9 +241,6 @@ struct TRI_doc_mptr_copy_t final : public TRI_doc_mptr_t {
}
TRI_doc_mptr_copy_t const& operator= (TRI_doc_mptr_t const& that) {
#ifdef TRI_ENABLE_MAINTAINER_MODE
triagens::arango::TransactionBase::assertCurrentTrxActive();
#endif
copy(that);
return *this;
}
@ -277,23 +256,13 @@ struct TRI_doc_mptr_copy_t final : public TRI_doc_mptr_t {
return std::move(*this);
}
#ifndef TRI_ENABLE_MAINTAINER_MODE
inline void const* getDataPtr () const {
return _dataptr;
}
#else
// The actual code has an assertion about transactions!
virtual void const* getDataPtr () const;
#endif
#ifndef TRI_ENABLE_MAINTAINER_MODE
inline void setDataPtr (void const* d) {
_dataptr = d;
}
#else
// The actual code has an assertion about transactions!
virtual void setDataPtr (void const* d);
#endif
};
@ -508,7 +477,7 @@ TRI_doc_datafile_info_t* TRI_FindDatafileInfoDocumentCollection (TRI_document_co
/// to ensure the collection is properly locked
////////////////////////////////////////////////////////////////////////////////
size_t TRI_DocumentIteratorDocumentCollection (triagens::arango::TransactionBase const*,
size_t TRI_DocumentIteratorDocumentCollection (triagens::arango::Transaction*,
TRI_document_collection_t*,
void*,
bool (*callback)(TRI_doc_mptr_t const*,
@ -816,7 +785,8 @@ bool TRI_IsFullyCollectedDocumentCollection (TRI_document_collection_t*);
/// @brief create an index, based on a JSON description
////////////////////////////////////////////////////////////////////////////////
int TRI_FromJsonIndexDocumentCollection (TRI_document_collection_t*,
int TRI_FromJsonIndexDocumentCollection (triagens::arango::Transaction*,
TRI_document_collection_t*,
struct TRI_json_t const*,
triagens::arango::Index**);
@ -824,7 +794,8 @@ int TRI_FromJsonIndexDocumentCollection (TRI_document_collection_t*,
/// @brief rolls back a document operation
////////////////////////////////////////////////////////////////////////////////
int TRI_RollbackOperationDocumentCollection (TRI_document_collection_t*,
int TRI_RollbackOperationDocumentCollection (triagens::arango::Transaction*,
TRI_document_collection_t*,
TRI_voc_document_operation_e,
TRI_doc_mptr_t*,
TRI_doc_mptr_copy_t const*);
@ -850,7 +821,8 @@ bool TRI_CloseDatafileDocumentCollection (TRI_document_collection_t*,
/// @brief fill the additional (non-primary) indexes
////////////////////////////////////////////////////////////////////////////////
int TRI_FillIndexesDocumentCollection (TRI_vocbase_col_t*,
int TRI_FillIndexesDocumentCollection (triagens::arango::Transaction*,
TRI_vocbase_col_t*,
TRI_document_collection_t*);
////////////////////////////////////////////////////////////////////////////////
@ -919,7 +891,8 @@ triagens::arango::Index* TRI_LookupCapConstraintDocumentCollection (TRI_document
/// @brief ensures that a cap constraint exists
////////////////////////////////////////////////////////////////////////////////
triagens::arango::Index* TRI_EnsureCapConstraintDocumentCollection (TRI_document_collection_t*,
triagens::arango::Index* TRI_EnsureCapConstraintDocumentCollection (triagens::arango::Transaction*,
TRI_document_collection_t*,
TRI_idx_iid_t,
size_t,
int64_t,
@ -957,7 +930,8 @@ triagens::arango::Index* TRI_LookupGeoIndex2DocumentCollection (TRI_document_col
/// @brief ensures that a geo index exists, list style
////////////////////////////////////////////////////////////////////////////////
triagens::arango::Index* TRI_EnsureGeoIndex1DocumentCollection (TRI_document_collection_t*,
triagens::arango::Index* TRI_EnsureGeoIndex1DocumentCollection (triagens::arango::Transaction*,
TRI_document_collection_t*,
TRI_idx_iid_t,
std::string const&,
bool,
@ -967,7 +941,8 @@ triagens::arango::Index* TRI_EnsureGeoIndex1DocumentCollection (TRI_document_col
/// @brief ensures that a geo index exists, attribute style
////////////////////////////////////////////////////////////////////////////////
triagens::arango::Index* TRI_EnsureGeoIndex2DocumentCollection (TRI_document_collection_t*,
triagens::arango::Index* TRI_EnsureGeoIndex2DocumentCollection (triagens::arango::Transaction*,
TRI_document_collection_t*,
TRI_idx_iid_t,
std::string const&,
std::string const&,
@ -998,7 +973,8 @@ triagens::arango::Index* TRI_LookupHashIndexDocumentCollection (TRI_document_col
/// @brief ensures that a hash index exists
////////////////////////////////////////////////////////////////////////////////
triagens::arango::Index* TRI_EnsureHashIndexDocumentCollection (TRI_document_collection_t*,
triagens::arango::Index* TRI_EnsureHashIndexDocumentCollection (triagens::arango::Transaction* trx,
TRI_document_collection_t*,
TRI_idx_iid_t,
std::vector<std::string> const&,
bool,
@ -1028,7 +1004,8 @@ triagens::arango::Index* TRI_LookupSkiplistIndexDocumentCollection (TRI_document
/// @brief ensures that a skiplist index exists
////////////////////////////////////////////////////////////////////////////////
triagens::arango::Index* TRI_EnsureSkiplistIndexDocumentCollection (TRI_document_collection_t*,
triagens::arango::Index* TRI_EnsureSkiplistIndexDocumentCollection (triagens::arango::Transaction* trx,
TRI_document_collection_t*,
TRI_idx_iid_t,
std::vector<std::string> const&,
bool,
@ -1057,7 +1034,8 @@ triagens::arango::Index* TRI_LookupFulltextIndexDocumentCollection (TRI_document
/// @brief ensures that a fulltext index exists
////////////////////////////////////////////////////////////////////////////////
triagens::arango::Index* TRI_EnsureFulltextIndexDocumentCollection (TRI_document_collection_t*,
triagens::arango::Index* TRI_EnsureFulltextIndexDocumentCollection (triagens::arango::Transaction* trx,
TRI_document_collection_t*,
TRI_idx_iid_t,
std::string const&,
int,
@ -1071,10 +1049,8 @@ triagens::arango::Index* TRI_EnsureFulltextIndexDocumentCollection (TRI_document
/// @brief executes a select-by-example query
////////////////////////////////////////////////////////////////////////////////
std::vector<TRI_doc_mptr_copy_t> TRI_SelectByExample (
struct TRI_transaction_collection_s*,
triagens::arango::ExampleMatcher& matcher
);
std::vector<TRI_doc_mptr_copy_t> TRI_SelectByExample (struct TRI_transaction_collection_s*,
triagens::arango::ExampleMatcher& matcher);
////////////////////////////////////////////////////////////////////////////////
/// @brief executes a select-by-example query
@ -1105,7 +1081,8 @@ struct ShapedJsonEq {
/// @brief deletes a documet given by a master pointer
////////////////////////////////////////////////////////////////////////////////
int TRI_DeleteDocumentDocumentCollection (struct TRI_transaction_collection_s*,
int TRI_DeleteDocumentDocumentCollection (triagens::arango::Transaction*,
struct TRI_transaction_collection_s*,
TRI_doc_update_policy_t const*,
TRI_doc_mptr_t*);
@ -1124,7 +1101,8 @@ int TRI_RotateJournalDocumentCollection (TRI_document_collection_t*);
/// @brief reads an element from the document collection
////////////////////////////////////////////////////////////////////////////////
int TRI_ReadShapedJsonDocumentCollection (TRI_transaction_collection_t*,
int TRI_ReadShapedJsonDocumentCollection (triagens::arango::Transaction*,
TRI_transaction_collection_t*,
const TRI_voc_key_t,
TRI_doc_mptr_copy_t*,
bool);
@ -1133,7 +1111,8 @@ int TRI_ReadShapedJsonDocumentCollection (TRI_transaction_collection_t*,
/// @brief removes a shaped-json document (or edge)
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveShapedJsonDocumentCollection (TRI_transaction_collection_t*,
int TRI_RemoveShapedJsonDocumentCollection (triagens::arango::Transaction*,
TRI_transaction_collection_t*,
const TRI_voc_key_t,
TRI_voc_rid_t,
triagens::wal::Marker*,
@ -1146,7 +1125,8 @@ int TRI_RemoveShapedJsonDocumentCollection (TRI_transaction_collection_t*,
/// note: key might be NULL. in this case, a key is auto-generated
////////////////////////////////////////////////////////////////////////////////
int TRI_InsertShapedJsonDocumentCollection (TRI_transaction_collection_t*,
int TRI_InsertShapedJsonDocumentCollection (triagens::arango::Transaction*,
TRI_transaction_collection_t*,
const TRI_voc_key_t,
TRI_voc_rid_t,
triagens::wal::Marker*,
@ -1161,7 +1141,8 @@ int TRI_InsertShapedJsonDocumentCollection (TRI_transaction_collection_t*,
/// @brief updates a document in the collection from shaped json
////////////////////////////////////////////////////////////////////////////////
int TRI_UpdateShapedJsonDocumentCollection (TRI_transaction_collection_t*,
int TRI_UpdateShapedJsonDocumentCollection (triagens::arango::Transaction*,
TRI_transaction_collection_t*,
const TRI_voc_key_t,
TRI_voc_rid_t,
triagens::wal::Marker*,

View File

@ -491,9 +491,6 @@ static int AppendDocument (triagens::wal::document_marker_t const* marker,
if (*((uint64_t*) legend) == 0ULL) {
// marker has no legend
// create a fake transaction so no assertion fails
triagens::arango::TransactionBase trx(true);
// try to open the collection and use the shaper
TRI_vocbase_t* vocbase = TRI_UseDatabaseByIdServer(dump->_vocbase->_server, marker->_databaseId);
@ -1187,14 +1184,6 @@ static int DumpCollection (TRI_replication_dump_t* dump,
bool bufferFull;
bool ignoreMarkers;
// The following fake transaction allows us to access data pointers
// and shapers, essentially disabling the runtime checks. This is OK,
// since the dump only considers data files (and not WAL files), so
// the collector has no trouble. Also, the data files of the collection
// are protected from the compactor by a barrier and the dump only goes
// until a certain tick.
triagens::arango::TransactionBase trx(true);
LOG_TRACE("dumping collection %llu, tick range %llu - %llu",
(unsigned long long) document->_info._cid,
(unsigned long long) dataMin,

View File

@ -154,131 +154,6 @@ typedef struct TRI_document_edge_s {
}
TRI_document_edge_t;
namespace triagens {
namespace arango {
// -----------------------------------------------------------------------------
// --SECTION-- class TransactionBase
// -----------------------------------------------------------------------------
//
class TransactionBase {
////////////////////////////////////////////////////////////////////////////////
/// @brief Transaction base, every transaction class has to inherit from here
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
TransactionBase () {
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxInScope >= 0);
TRI_ASSERT(_numberTrxInScope == _numberTrxActive);
_numberTrxInScope++;
#endif
}
explicit TransactionBase (bool standalone) {
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxInScope >= 0);
TRI_ASSERT(_numberTrxInScope == _numberTrxActive);
_numberTrxInScope++;
if (standalone) {
_numberTrxActive++;
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////
virtual ~TransactionBase () {
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxInScope > 0);
_numberTrxInScope--;
// Note that embedded transactions might have seen a begin()
// but no abort() or commit(), so _numberTrxActive might
// be one too big. We simply fix it here:
_numberTrxActive = _numberTrxInScope;
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief set counters, used in replication client to transfer transactions
/// between threads.
////////////////////////////////////////////////////////////////////////////////
static void setNumbers (int numberInScope, int numberActive) {
#ifdef TRI_ENABLE_MAINTAINER_MODE
_numberTrxInScope = numberInScope;
_numberTrxActive = numberActive;
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief increase counters, used in replication client in shutdown to
/// kill transactions of other threads.
////////////////////////////////////////////////////////////////////////////////
static void increaseNumbers (int numberInScope, int numberActive) {
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxInScope + numberInScope >= 0);
TRI_ASSERT(_numberTrxActive + numberActive >= 0);
_numberTrxInScope += numberInScope;
_numberTrxActive += numberActive;
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief assert that a transaction object is in scope in the current thread
////////////////////////////////////////////////////////////////////////////////
static void assertSomeTrxInScope () {
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxInScope > 0);
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief assert that the innermost transaction object in scope in the
/// current thread is actually active (between begin() and commit()/abort().
////////////////////////////////////////////////////////////////////////////////
static void assertCurrentTrxActive () {
#ifdef TRI_ENABLE_MAINTAINER_MODE
TRI_ASSERT(_numberTrxInScope > 0 &&
_numberTrxInScope == _numberTrxActive);
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in scope in the current thread
////////////////////////////////////////////////////////////////////////////////
protected:
#ifdef TRI_ENABLE_MAINTAINER_MODE
static thread_local int _numberTrxInScope;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in the current thread that are active (between
/// begin and commit()/abort().
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_ENABLE_MAINTAINER_MODE
static thread_local int _numberTrxActive;
#endif
};
}
}
#endif
// -----------------------------------------------------------------------------

View File

@ -677,9 +677,6 @@ int CollectorThread::processCollectionOperations (CollectorCache* cache) {
TRI_ASSERT(collection != nullptr);
// create a fake transaction while accessing the collection
triagens::arango::TransactionBase trx(true);
TRI_document_collection_t* document = collection->_collection;
// first try to read-lock the compactor-lock, afterwards try to write-lock the collection

View File

@ -11,6 +11,10 @@
struct TRI_transaction_collection_s;
namespace triagens {
namespace arango {
class Transaction;
}
namespace wal {
class Marker;
@ -23,12 +27,14 @@ namespace triagens {
REVERTED
};
DocumentOperation (Marker* marker,
DocumentOperation (triagens::arango::Transaction* trx,
Marker* marker,
bool freeMarker,
TRI_document_collection_t* document,
TRI_voc_document_operation_e type,
TRI_voc_rid_t rid)
: marker(marker),
: trx(trx),
marker(marker),
document(document),
header(nullptr),
rid(rid),
@ -56,7 +62,7 @@ namespace triagens {
}
DocumentOperation* swap () {
DocumentOperation* copy = new DocumentOperation(marker, freeMarker, document, type, rid);
DocumentOperation* copy = new DocumentOperation(trx, marker, freeMarker, document, type, rid);
copy->tick = tick;
copy->header = header;
copy->oldHeader = oldHeader;
@ -105,7 +111,7 @@ namespace triagens {
}
if (status == StatusType::INDEXED || status == StatusType::HANDLED) {
TRI_RollbackOperationDocumentCollection(document, type, header, &oldHeader);
TRI_RollbackOperationDocumentCollection(trx, document, type, header, &oldHeader);
}
if (type == TRI_VOC_DOCUMENT_OPERATION_INSERT) {
@ -124,6 +130,7 @@ namespace triagens {
status = StatusType::REVERTED;
}
triagens::arango::Transaction* trx;
Marker* marker;
TRI_document_collection_t* document;
TRI_doc_mptr_t* header;

View File

@ -33,6 +33,8 @@
#include "Basics/files.h"
#include "Basics/Exceptions.h"
#include "Basics/memory-map.h"
#include "Utils/SingleCollectionWriteTransaction.h"
#include "Utils/StandaloneTransactionContext.h"
#include "VocBase/collection.h"
#include "VocBase/replication-applier.h"
#include "VocBase/VocShaper.h"
@ -716,11 +718,11 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
}
TRI_doc_mptr_copy_t mptr;
int res = TRI_InsertShapedJsonDocumentCollection(trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, nullptr, false, false, true);
int res = TRI_InsertShapedJsonDocumentCollection(trx, trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, nullptr, false, false, true);
if (res == TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED) {
state->policy.setExpectedRevision(m->_revisionId);
res = TRI_UpdateShapedJsonDocumentCollection(trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, &state->policy, false, false);
res = TRI_UpdateShapedJsonDocumentCollection(trx, trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, &state->policy, false, false);
}
return res;
@ -773,11 +775,11 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
}
TRI_doc_mptr_copy_t mptr;
int res = TRI_InsertShapedJsonDocumentCollection(trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, &edge, false, false, true);
int res = TRI_InsertShapedJsonDocumentCollection(trx, trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, &edge, false, false, true);
if (res == TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED) {
state->policy.setExpectedRevision(m->_revisionId);
res = TRI_UpdateShapedJsonDocumentCollection(trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, &state->policy, false, false);
res = TRI_UpdateShapedJsonDocumentCollection(trx, trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &mptr, &shaped, &state->policy, false, false);
}
return res;
@ -823,7 +825,7 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
// remove the document and ignore any potential errors
state->policy.setExpectedRevision(m->_revisionId);
TRI_RemoveShapedJsonDocumentCollection(trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &state->policy, false, false);
TRI_RemoveShapedJsonDocumentCollection(trx, trx->trxCollection(), (TRI_voc_key_t) key, m->_revisionId, envelope, &state->policy, false, false);
return TRI_ERROR_NO_ERROR;
});
@ -1041,9 +1043,6 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
return state->canContinue();
}
// fake transaction to satisfy assertions
triagens::arango::TransactionBase trx(true);
std::string collectionDirectory = GetCollectionDirectory(vocbase, collectionId);
char* idString = TRI_StringUInt64(indexId);
char* indexName = TRI_Concatenate3String("index-", idString, ".json");
@ -1140,9 +1139,6 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
TRI_FromJsonCollectionInfo(&info, json);
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
// fake transaction to satisfy assertions
triagens::arango::TransactionBase trx(true);
WaitForDeletion(vocbase, collectionId, TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
if (state->willBeDropped(collectionId)) {
@ -1225,9 +1221,6 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
TRI_vocbase_defaults_t defaults;
TRI_GetDatabaseDefaultsServer(state->server, &defaults);
// fake transaction to satisfy assertions
triagens::arango::TransactionBase trx(true);
vocbase = nullptr;
WaitForDeletion(state->server, databaseId, TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
int res = TRI_CreateDatabaseServer(state->server, databaseId, nameString.c_str(), &defaults, &vocbase, false);
@ -1269,9 +1262,6 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
return true;
}
// fake transaction to satisfy assertions
triagens::arango::TransactionBase trx(true);
// ignore any potential error returned by this call
TRI_DropIndexDocumentCollection(document, indexId, false);
TRI_RemoveFileIndexCollection(document, indexId);
@ -1312,9 +1302,6 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
}
if (collection != nullptr) {
// fake transaction to satisfy assertions
triagens::arango::TransactionBase trx(true);
int statusCode = TRI_DropCollectionVocBase(vocbase, collection, false);
WaitForDeletion(vocbase, collectionId, statusCode);
}
@ -1331,9 +1318,6 @@ bool RecoverState::ReplayMarker (TRI_df_marker_t const* marker,
TRI_vocbase_t* vocbase = state->releaseDatabase(databaseId);
if (vocbase != nullptr) {
// fake transaction to satisfy assertions
triagens::arango::TransactionBase trx(true);
// ignore any potential error returned by this call
TRI_DropByIdDatabaseServer(state->server, databaseId, false, false);
}
@ -1467,13 +1451,9 @@ int RecoverState::removeEmptyLogfiles () {
////////////////////////////////////////////////////////////////////////////////
int RecoverState::fillIndexes () {
// fake transaction to allow populating the secondary indexes
triagens::arango::TransactionBase trx(true);
// release all collections
for (auto it = openedCollections.begin(); it != openedCollections.end(); ++it) {
TRI_vocbase_col_t* collection = (*it).second;
TRI_document_collection_t* document = collection->_collection;
TRI_ASSERT(document != nullptr);
@ -1481,7 +1461,9 @@ int RecoverState::fillIndexes () {
// activate secondary indexes
document->useSecondaryIndexes(true);
int res = TRI_FillIndexesDocumentCollection(collection, document);
triagens::arango::SingleCollectionWriteTransaction<UINT64_MAX> trx(new triagens::arango::StandaloneTransactionContext(), collection->_vocbase, document->_info._cid);
int res = TRI_FillIndexesDocumentCollection(&trx, collection, document);
if (res != TRI_ERROR_NO_ERROR) {
return res;