mirror of https://gitee.com/bigwinds/arangodb
more assertions
This commit is contained in:
parent
adfd051c92
commit
ebc61295e7
|
@ -765,7 +765,7 @@ static int RollbackInsert (TRI_document_collection_t* document,
|
|||
DeleteSecondaryIndexes(document, newHeader, true);
|
||||
|
||||
// release the header. nobody else should point to it now
|
||||
document->_headers->release(document->_headers, newHeader);
|
||||
document->_headers->release(document->_headers, newHeader, true);
|
||||
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
|
@ -901,7 +901,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// insert has failed
|
||||
document->_headers->release(document->_headers, header);
|
||||
document->_headers->release(document->_headers, header, true);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// insertion into secondary indexes failed
|
||||
DeletePrimaryIndex(document, header, true);
|
||||
document->_headers->release(document->_headers, header);
|
||||
document->_headers->release(document->_headers, header, true);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1099,7 +1099,7 @@ static int RemoveDocument (TRI_transaction_collection_t* trxCollection,
|
|||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
if (directOperation) {
|
||||
// release the header pointer
|
||||
document->_headers->release(document->_headers, header);
|
||||
document->_headers->release(document->_headers, header, true);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
@ -1965,7 +1965,7 @@ static int OpenIteratorApplyInsert (open_iterator_state_t* state,
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// insertion failed
|
||||
LOG_ERROR("inserting document into indexes failed");
|
||||
document->_headers->release(document->_headers, header);
|
||||
document->_headers->release(document->_headers, header, true);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -2116,7 +2116,7 @@ static int OpenIteratorApplyRemove (open_iterator_state_t* state,
|
|||
DeletePrimaryIndex(document, found, false);
|
||||
|
||||
// free the header
|
||||
document->_headers->release(document->_headers, CONST_CAST(found));
|
||||
document->_headers->release(document->_headers, CONST_CAST(found), true);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
|
|
@ -96,7 +96,7 @@ static size_t GetBlockSize (const size_t blockNumber) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clears an header
|
||||
/// @brief clears a header
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void ClearHeader (TRI_headers_t* h,
|
||||
|
@ -172,6 +172,8 @@ static void MoveBackHeader (TRI_headers_t* h,
|
|||
// we must adjust the size of the collection
|
||||
headers->_totalSize += (int64_t) (((TRI_df_marker_t*) header->_data)->_size);
|
||||
headers->_totalSize -= (int64_t) (((TRI_df_marker_t*) old->_data)->_size);
|
||||
|
||||
TRI_ASSERT_MAINTAINER(headers->_totalSize > 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -424,7 +426,7 @@ static TRI_doc_mptr_t* RequestHeader (TRI_headers_t* h,
|
|||
headers->_nrAllocated++;
|
||||
headers->_nrLinked++;
|
||||
headers->_totalSize += (int64_t) size;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -433,14 +435,17 @@ static TRI_doc_mptr_t* RequestHeader (TRI_headers_t* h,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void ReleaseHeader (TRI_headers_t* h,
|
||||
TRI_doc_mptr_t* header) {
|
||||
TRI_doc_mptr_t* header,
|
||||
bool unlink) {
|
||||
simple_headers_t* headers = (simple_headers_t*) h;
|
||||
|
||||
if (header == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
UnlinkHeader(h, header);
|
||||
if (unlink) {
|
||||
UnlinkHeader(h, header);
|
||||
}
|
||||
ClearHeader(h, header);
|
||||
|
||||
header->_data = headers->_freelist;
|
||||
|
@ -504,6 +509,8 @@ static void DumpHeaders (TRI_headers_t const* h) {
|
|||
|
||||
printf("number of allocated headers: %lu\n", (unsigned long) headers->_nrAllocated);
|
||||
printf("number of linked headers: %lu\n", (unsigned long) headers->_nrLinked);
|
||||
printf("total size: %lld\n", (long long) headers->_totalSize);
|
||||
|
||||
printf("begin ptr: %p\n", headers->_begin);
|
||||
printf("end ptr: %p\n", headers->_end);
|
||||
|
||||
|
@ -575,7 +582,7 @@ TRI_headers_t* TRI_CreateSimpleHeaders () {
|
|||
headers->base.dump = DumpHeaders;
|
||||
#endif
|
||||
|
||||
TRI_InitVectorPointer(&headers->_blocks, TRI_UNKNOWN_MEM_ZONE);
|
||||
TRI_InitVectorPointer2(&headers->_blocks, TRI_UNKNOWN_MEM_ZONE, 8);
|
||||
|
||||
return &headers->base;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ typedef struct TRI_headers_s {
|
|||
struct TRI_doc_mptr_s* (*request) (struct TRI_headers_s*, size_t);
|
||||
|
||||
// release/free an existing header, putting it back onto the freelist
|
||||
void (*release) (struct TRI_headers_s*, struct TRI_doc_mptr_s*);
|
||||
void (*release) (struct TRI_headers_s*, struct TRI_doc_mptr_s*, bool unlink);
|
||||
|
||||
// move an existing header to the end of the linked list
|
||||
void (*moveBack) (struct TRI_headers_s*, struct TRI_doc_mptr_s*, struct TRI_doc_mptr_s*);
|
||||
|
|
|
@ -977,7 +977,7 @@ static void FreeCollectionOperations (TRI_transaction_collection_t* trxCollectio
|
|||
|
||||
if (wasCommitted) {
|
||||
if (trxOperation->_type == TRI_VOC_DOCUMENT_OPERATION_REMOVE) {
|
||||
document->_headers->release(document->_headers, trxOperation->_oldHeader);
|
||||
document->_headers->release(document->_headers, trxOperation->_oldHeader, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1866,7 +1866,6 @@ int TRI_CommitTransaction (TRI_transaction_t* const trx,
|
|||
if (nestingLevel == 0) {
|
||||
if (trx->_hasOperations) {
|
||||
res = WriteOperations(trx);
|
||||
FreeOperations(trx);
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
|
@ -1876,6 +1875,10 @@ int TRI_CommitTransaction (TRI_transaction_t* const trx,
|
|||
else {
|
||||
res = UpdateTransactionStatus(trx, TRI_TRANSACTION_COMMITTED);
|
||||
}
|
||||
|
||||
if (trx->_hasOperations) {
|
||||
FreeOperations(trx);
|
||||
}
|
||||
}
|
||||
|
||||
ReleaseCollections(trx, nestingLevel);
|
||||
|
@ -1898,10 +1901,12 @@ int TRI_AbortTransaction (TRI_transaction_t* const trx,
|
|||
if (nestingLevel == 0) {
|
||||
if (trx->_hasOperations) {
|
||||
RollbackOperations(trx);
|
||||
FreeOperations(trx);
|
||||
}
|
||||
|
||||
res = UpdateTransactionStatus(trx, TRI_TRANSACTION_ABORTED);
|
||||
if (trx->_hasOperations) {
|
||||
FreeOperations(trx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
|
|
Loading…
Reference in New Issue