mirror of https://gitee.com/bigwinds/arangodb
more asserts
This commit is contained in:
parent
3301813f3c
commit
35a81dc54d
|
@ -59,21 +59,21 @@ static int ApplyCap (TRI_cap_constraint_t* cap,
|
||||||
|
|
||||||
res = TRI_ERROR_NO_ERROR;
|
res = TRI_ERROR_NO_ERROR;
|
||||||
|
|
||||||
// delete while at least one of the constraints is violated
|
// delete while at least one of the constraints is still violated
|
||||||
while ((cap->_count > 0 && currentCount > cap->_count) ||
|
while ((cap->_count > 0 && currentCount > cap->_count) ||
|
||||||
(cap->_size > 0 && currentSize > cap->_size)) {
|
(cap->_size > 0 && currentSize > cap->_size)) {
|
||||||
TRI_doc_mptr_t* oldest = headers->front();
|
TRI_doc_mptr_t* oldest = headers->front();
|
||||||
|
|
||||||
if (oldest != NULL) {
|
if (oldest != nullptr) {
|
||||||
size_t oldSize;
|
size_t oldSize;
|
||||||
|
|
||||||
TRI_ASSERT(oldest->getDataPtr() != NULL); // ONLY IN INDEX, PROTECTED by RUNTIME
|
TRI_ASSERT(oldest->getDataPtr() != nullptr); // ONLY IN INDEX, PROTECTED by RUNTIME
|
||||||
oldSize = ((TRI_df_marker_t*) (oldest->getDataPtr()))->_size; // ONLY IN INDEX, PROTECTED by RUNTIME
|
oldSize = ((TRI_df_marker_t*) (oldest->getDataPtr()))->_size; // ONLY IN INDEX, PROTECTED by RUNTIME
|
||||||
|
|
||||||
TRI_ASSERT(oldSize > 0);
|
TRI_ASSERT(oldSize > 0);
|
||||||
|
|
||||||
if (trxCollection != NULL) {
|
if (trxCollection != nullptr) {
|
||||||
res = TRI_DeleteDocumentDocumentCollection(trxCollection, NULL, oldest);
|
res = TRI_DeleteDocumentDocumentCollection(trxCollection, nullptr, oldest);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
LOG_WARNING("cannot cap collection: %s", TRI_errno_string(res));
|
LOG_WARNING("cannot cap collection: %s", TRI_errno_string(res));
|
||||||
|
@ -113,7 +113,7 @@ static int InitialiseCap (TRI_cap_constraint_t* cap,
|
||||||
currentCount = headers->count();
|
currentCount = headers->count();
|
||||||
currentSize = headers->size();
|
currentSize = headers->size();
|
||||||
|
|
||||||
if ((cap->_count >0 && currentCount <= cap->_count) &&
|
if ((cap->_count > 0 && currentCount <= cap->_count) &&
|
||||||
(cap->_size > 0 && currentSize <= cap->_size)) {
|
(cap->_size > 0 && currentSize <= cap->_size)) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
|
@ -127,9 +127,11 @@ static int InitialiseCap (TRI_cap_constraint_t* cap,
|
||||||
vocbase = document->_vocbase;
|
vocbase = document->_vocbase;
|
||||||
cid = document->_info._cid;
|
cid = document->_info._cid;
|
||||||
|
|
||||||
|
// create a fake transaction to avoid assertion failures TODO: FIXME
|
||||||
|
triagens::arango::TransactionBase fake(true);
|
||||||
trx = TRI_CreateTransaction(vocbase, TRI_GetIdServer(), true, 0.0, false);
|
trx = TRI_CreateTransaction(vocbase, TRI_GetIdServer(), true, 0.0, false);
|
||||||
|
|
||||||
if (trx == NULL) {
|
if (trx == nullptr) {
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +142,7 @@ static int InitialiseCap (TRI_cap_constraint_t* cap,
|
||||||
|
|
||||||
trxCollection = TRI_GetCollectionTransaction(trx, cid, TRI_TRANSACTION_WRITE);
|
trxCollection = TRI_GetCollectionTransaction(trx, cid, TRI_TRANSACTION_WRITE);
|
||||||
|
|
||||||
if (trxCollection != NULL) {
|
if (trxCollection != nullptr) {
|
||||||
res = TRI_BeginTransaction(trx, (TRI_transaction_hint_t) TRI_TRANSACTION_HINT_LOCK_NEVER, TRI_TRANSACTION_TOP_LEVEL);
|
res = TRI_BeginTransaction(trx, (TRI_transaction_hint_t) TRI_TRANSACTION_HINT_LOCK_NEVER, TRI_TRANSACTION_TOP_LEVEL);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
|
@ -186,8 +188,8 @@ static TRI_json_t* JsonCapConstraint (TRI_index_t const* idx) {
|
||||||
// create json object and fill it
|
// create json object and fill it
|
||||||
json = TRI_JsonIndex(TRI_CORE_MEM_ZONE, idx);
|
json = TRI_JsonIndex(TRI_CORE_MEM_ZONE, idx);
|
||||||
|
|
||||||
if (json == NULL) {
|
if (json == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "size", TRI_CreateNumberJson(TRI_CORE_MEM_ZONE, (double) cap->_count));
|
TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "size", TRI_CreateNumberJson(TRI_CORE_MEM_ZONE, (double) cap->_count));
|
||||||
|
@ -202,7 +204,7 @@ static TRI_json_t* JsonCapConstraint (TRI_index_t const* idx) {
|
||||||
|
|
||||||
static void RemoveIndexCapConstraint (TRI_index_t* idx,
|
static void RemoveIndexCapConstraint (TRI_index_t* idx,
|
||||||
TRI_document_collection_t* document) {
|
TRI_document_collection_t* document) {
|
||||||
document->_capConstraint = NULL;
|
document->_capConstraint = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -269,8 +271,8 @@ TRI_index_t* TRI_CreateCapConstraint (TRI_document_collection_t* document,
|
||||||
int64_t size) {
|
int64_t size) {
|
||||||
TRI_cap_constraint_t* cap = static_cast<TRI_cap_constraint_t*>(TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_cap_constraint_t), false));
|
TRI_cap_constraint_t* cap = static_cast<TRI_cap_constraint_t*>(TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_cap_constraint_t), false));
|
||||||
|
|
||||||
if (cap == NULL) {
|
if (cap == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_index_t* idx = &cap->base;
|
TRI_index_t* idx = &cap->base;
|
||||||
|
|
|
@ -52,11 +52,6 @@ namespace triagens {
|
||||||
// --SECTION-- constructors and destructors
|
// --SECTION-- constructors and destructors
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup ArangoDB
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -102,15 +97,6 @@ namespace triagens {
|
||||||
virtual ~SingleCollectionWriteTransaction () {
|
virtual ~SingleCollectionWriteTransaction () {
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup ArangoDB
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public functions
|
// --SECTION-- public functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -139,10 +125,12 @@ namespace triagens {
|
||||||
|
|
||||||
int createDocument (TRI_doc_mptr_copy_t* mptr,
|
int createDocument (TRI_doc_mptr_copy_t* mptr,
|
||||||
TRI_json_t const* json,
|
TRI_json_t const* json,
|
||||||
const bool forceSync) {
|
bool forceSync) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
|
|
||||||
|
@ -162,10 +150,11 @@ namespace triagens {
|
||||||
TRI_json_t const* json,
|
TRI_json_t const* json,
|
||||||
bool forceSync,
|
bool forceSync,
|
||||||
void const* data) {
|
void const* data) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
|
|
||||||
|
@ -185,9 +174,11 @@ namespace triagens {
|
||||||
TRI_doc_mptr_copy_t* mptr,
|
TRI_doc_mptr_copy_t* mptr,
|
||||||
TRI_shaped_json_t const* shaped,
|
TRI_shaped_json_t const* shaped,
|
||||||
bool forceSync) {
|
bool forceSync) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
|
|
||||||
|
@ -209,9 +200,11 @@ namespace triagens {
|
||||||
TRI_shaped_json_t const* shaped,
|
TRI_shaped_json_t const* shaped,
|
||||||
bool forceSync,
|
bool forceSync,
|
||||||
void const* data) {
|
void const* data) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
|
|
||||||
|
@ -229,16 +222,18 @@ namespace triagens {
|
||||||
/// using json
|
/// using json
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int updateDocument (const string& key,
|
int updateDocument (std::string const& key,
|
||||||
TRI_doc_mptr_copy_t* mptr,
|
TRI_doc_mptr_copy_t* mptr,
|
||||||
TRI_json_t* const json,
|
TRI_json_t* const json,
|
||||||
const TRI_doc_update_policy_e policy,
|
TRI_doc_update_policy_e policy,
|
||||||
bool forceSync,
|
bool forceSync,
|
||||||
const TRI_voc_rid_t expectedRevision,
|
TRI_voc_rid_t expectedRevision,
|
||||||
TRI_voc_rid_t* actualRevision) {
|
TRI_voc_rid_t* actualRevision) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
|
|
||||||
|
@ -258,16 +253,18 @@ namespace triagens {
|
||||||
/// using shaped json
|
/// using shaped json
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int updateDocument (const string& key,
|
int updateDocument (std::string const& key,
|
||||||
TRI_doc_mptr_copy_t* mptr,
|
TRI_doc_mptr_copy_t* mptr,
|
||||||
TRI_shaped_json_t* const shaped,
|
TRI_shaped_json_t* const shaped,
|
||||||
const TRI_doc_update_policy_e policy,
|
TRI_doc_update_policy_e policy,
|
||||||
bool forceSync,
|
bool forceSync,
|
||||||
const TRI_voc_rid_t expectedRevision,
|
TRI_voc_rid_t expectedRevision,
|
||||||
TRI_voc_rid_t* actualRevision) {
|
TRI_voc_rid_t* actualRevision) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
|
|
||||||
|
@ -286,14 +283,16 @@ namespace triagens {
|
||||||
/// @brief delete a single document within a transaction
|
/// @brief delete a single document within a transaction
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int deleteDocument (const string& key,
|
int deleteDocument (std::string const& key,
|
||||||
const TRI_doc_update_policy_e policy,
|
TRI_doc_update_policy_e policy,
|
||||||
bool forceSync,
|
bool forceSync,
|
||||||
const TRI_voc_rid_t expectedRevision,
|
TRI_voc_rid_t expectedRevision,
|
||||||
TRI_voc_rid_t* actualRevision) {
|
TRI_voc_rid_t* actualRevision) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return this->remove(this->trxCollection(),
|
return this->remove(this->trxCollection(),
|
||||||
key,
|
key,
|
||||||
|
@ -309,26 +308,18 @@ namespace triagens {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int truncate (bool forceSync) {
|
int truncate (bool forceSync) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
if (_numWrites++ > N) {
|
if (_numWrites++ > N) {
|
||||||
return TRI_ERROR_TRANSACTION_INTERNAL;
|
return TRI_ERROR_TRANSACTION_INTERNAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return this->removeAll(this->trxCollection(), forceSync);
|
return this->removeAll(this->trxCollection(), forceSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- private variables
|
// --SECTION-- private variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup ArangoDB
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -339,10 +330,6 @@ namespace triagens {
|
||||||
|
|
||||||
uint64_t _numWrites;
|
uint64_t _numWrites;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -707,7 +707,7 @@ static int PostInsertIndexes (TRI_transaction_collection_t* trxCollection,
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
TRI_index_t* idx = static_cast<TRI_index_t*>(document->_allIndexes._buffer[i]);
|
TRI_index_t* idx = static_cast<TRI_index_t*>(document->_allIndexes._buffer[i]);
|
||||||
|
|
||||||
if (idx->postInsert != NULL) {
|
if (idx->postInsert != nullptr) {
|
||||||
idx->postInsert(trxCollection, idx, header);
|
idx->postInsert(trxCollection, idx, header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5227,9 +5227,6 @@ std::vector<TRI_doc_mptr_copy_t> TRI_SelectByExample (
|
||||||
int TRI_DeleteDocumentDocumentCollection (TRI_transaction_collection_t* trxCollection,
|
int TRI_DeleteDocumentDocumentCollection (TRI_transaction_collection_t* trxCollection,
|
||||||
TRI_doc_update_policy_t const* policy,
|
TRI_doc_update_policy_t const* policy,
|
||||||
TRI_doc_mptr_t* doc) {
|
TRI_doc_mptr_t* doc) {
|
||||||
// no extra locking here as the collection is already locked
|
|
||||||
TRI_ASSERT(TRI_IsLockedCollectionTransaction(trxCollection, TRI_TRANSACTION_WRITE, 0));
|
|
||||||
|
|
||||||
return TRI_RemoveShapedJsonDocumentCollection(trxCollection,
|
return TRI_RemoveShapedJsonDocumentCollection(trxCollection,
|
||||||
(const TRI_voc_key_t) TRI_EXTRACT_MARKER_KEY(doc),
|
(const TRI_voc_key_t) TRI_EXTRACT_MARKER_KEY(doc),
|
||||||
0,
|
0,
|
||||||
|
@ -5387,6 +5384,7 @@ int TRI_InsertShapedJsonDocumentCollection (TRI_transaction_collection_t* trxCol
|
||||||
TRI_voc_tick_t tick = static_cast<TRI_voc_tick_t>(rid);
|
TRI_voc_tick_t tick = static_cast<TRI_voc_tick_t>(rid);
|
||||||
|
|
||||||
TRI_document_collection_t* document = trxCollection->_collection->_collection;
|
TRI_document_collection_t* document = trxCollection->_collection->_collection;
|
||||||
|
TRI_ASSERT_EXPENSIVE(lock || TRI_IsLockedCollectionTransaction(trxCollection, TRI_TRANSACTION_WRITE, 0));
|
||||||
TRI_key_generator_t* keyGenerator = static_cast<TRI_key_generator_t*>(document->_keyGenerator);
|
TRI_key_generator_t* keyGenerator = static_cast<TRI_key_generator_t*>(document->_keyGenerator);
|
||||||
|
|
||||||
std::string keyString;
|
std::string keyString;
|
||||||
|
@ -5502,6 +5500,7 @@ int TRI_UpdateShapedJsonDocumentCollection (TRI_transaction_collection_t* trxCol
|
||||||
mptr->setDataPtr(nullptr); // PROTECTED by trx in trxCollection
|
mptr->setDataPtr(nullptr); // PROTECTED by trx in trxCollection
|
||||||
|
|
||||||
TRI_document_collection_t* document = trxCollection->_collection->_collection;
|
TRI_document_collection_t* document = trxCollection->_collection->_collection;
|
||||||
|
TRI_ASSERT_EXPENSIVE(lock || TRI_IsLockedCollectionTransaction(trxCollection, TRI_TRANSACTION_WRITE, 0));
|
||||||
|
|
||||||
// create legend
|
// create legend
|
||||||
triagens::basics::JsonLegend legend(document->getShaper()); // PROTECTED by trx in trxCollection
|
triagens::basics::JsonLegend legend(document->getShaper()); // PROTECTED by trx in trxCollection
|
||||||
|
|
|
@ -841,7 +841,8 @@ bool TRI_IsLockedCollectionTransaction (TRI_transaction_collection_t* trxCollect
|
||||||
TRI_transaction_type_e accessType,
|
TRI_transaction_type_e accessType,
|
||||||
int nestingLevel) {
|
int nestingLevel) {
|
||||||
|
|
||||||
if (accessType == TRI_TRANSACTION_WRITE && trxCollection->_accessType != TRI_TRANSACTION_WRITE) {
|
if (accessType == TRI_TRANSACTION_WRITE &&
|
||||||
|
trxCollection->_accessType != TRI_TRANSACTION_WRITE) {
|
||||||
// wrong lock type
|
// wrong lock type
|
||||||
LOG_WARNING("logic error. checking wrong lock type");
|
LOG_WARNING("logic error. checking wrong lock type");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue