1
0
Fork 0

more assertions

This commit is contained in:
Jan Steemann 2013-06-24 14:25:21 +02:00
parent adfd051c92
commit ebc61295e7
4 changed files with 27 additions and 15 deletions

View File

@ -765,7 +765,7 @@ static int RollbackInsert (TRI_document_collection_t* document,
DeleteSecondaryIndexes(document, newHeader, true); DeleteSecondaryIndexes(document, newHeader, true);
// release the header. nobody else should point to it now // 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; res = TRI_ERROR_NO_ERROR;
@ -901,7 +901,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
// insert has failed // insert has failed
document->_headers->release(document->_headers, header); document->_headers->release(document->_headers, header, true);
return res; return res;
} }
@ -911,7 +911,7 @@ static int InsertDocument (TRI_transaction_collection_t* trxCollection,
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
// insertion into secondary indexes failed // insertion into secondary indexes failed
DeletePrimaryIndex(document, header, true); DeletePrimaryIndex(document, header, true);
document->_headers->release(document->_headers, header); document->_headers->release(document->_headers, header, true);
return res; return res;
} }
@ -1099,7 +1099,7 @@ static int RemoveDocument (TRI_transaction_collection_t* trxCollection,
if (res == TRI_ERROR_NO_ERROR) { if (res == TRI_ERROR_NO_ERROR) {
if (directOperation) { if (directOperation) {
// release the header pointer // release the header pointer
document->_headers->release(document->_headers, header); document->_headers->release(document->_headers, header, true);
} }
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
@ -1965,7 +1965,7 @@ static int OpenIteratorApplyInsert (open_iterator_state_t* state,
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
// insertion failed // insertion failed
LOG_ERROR("inserting document into indexes failed"); LOG_ERROR("inserting document into indexes failed");
document->_headers->release(document->_headers, header); document->_headers->release(document->_headers, header, true);
return res; return res;
} }
@ -2116,7 +2116,7 @@ static int OpenIteratorApplyRemove (open_iterator_state_t* state,
DeletePrimaryIndex(document, found, false); DeletePrimaryIndex(document, found, false);
// free the header // 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; return TRI_ERROR_NO_ERROR;

View File

@ -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, 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 // 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*) header->_data)->_size);
headers->_totalSize -= (int64_t) (((TRI_df_marker_t*) old->_data)->_size); headers->_totalSize -= (int64_t) (((TRI_df_marker_t*) old->_data)->_size);
TRI_ASSERT_MAINTAINER(headers->_totalSize > 0);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -433,14 +435,17 @@ static TRI_doc_mptr_t* RequestHeader (TRI_headers_t* h,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void ReleaseHeader (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; simple_headers_t* headers = (simple_headers_t*) h;
if (header == NULL) { if (header == NULL) {
return; return;
} }
if (unlink) {
UnlinkHeader(h, header); UnlinkHeader(h, header);
}
ClearHeader(h, header); ClearHeader(h, header);
header->_data = headers->_freelist; 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 allocated headers: %lu\n", (unsigned long) headers->_nrAllocated);
printf("number of linked headers: %lu\n", (unsigned long) headers->_nrLinked); 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("begin ptr: %p\n", headers->_begin);
printf("end ptr: %p\n", headers->_end); printf("end ptr: %p\n", headers->_end);
@ -575,7 +582,7 @@ TRI_headers_t* TRI_CreateSimpleHeaders () {
headers->base.dump = DumpHeaders; headers->base.dump = DumpHeaders;
#endif #endif
TRI_InitVectorPointer(&headers->_blocks, TRI_UNKNOWN_MEM_ZONE); TRI_InitVectorPointer2(&headers->_blocks, TRI_UNKNOWN_MEM_ZONE, 8);
return &headers->base; return &headers->base;
} }

View File

@ -58,7 +58,7 @@ typedef struct TRI_headers_s {
struct TRI_doc_mptr_s* (*request) (struct TRI_headers_s*, size_t); struct TRI_doc_mptr_s* (*request) (struct TRI_headers_s*, size_t);
// release/free an existing header, putting it back onto the freelist // 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 // 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*); void (*moveBack) (struct TRI_headers_s*, struct TRI_doc_mptr_s*, struct TRI_doc_mptr_s*);

View File

@ -977,7 +977,7 @@ static void FreeCollectionOperations (TRI_transaction_collection_t* trxCollectio
if (wasCommitted) { if (wasCommitted) {
if (trxOperation->_type == TRI_VOC_DOCUMENT_OPERATION_REMOVE) { 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 (nestingLevel == 0) {
if (trx->_hasOperations) { if (trx->_hasOperations) {
res = WriteOperations(trx); res = WriteOperations(trx);
FreeOperations(trx);
} }
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
@ -1876,6 +1875,10 @@ int TRI_CommitTransaction (TRI_transaction_t* const trx,
else { else {
res = UpdateTransactionStatus(trx, TRI_TRANSACTION_COMMITTED); res = UpdateTransactionStatus(trx, TRI_TRANSACTION_COMMITTED);
} }
if (trx->_hasOperations) {
FreeOperations(trx);
}
} }
ReleaseCollections(trx, nestingLevel); ReleaseCollections(trx, nestingLevel);
@ -1898,10 +1901,12 @@ int TRI_AbortTransaction (TRI_transaction_t* const trx,
if (nestingLevel == 0) { if (nestingLevel == 0) {
if (trx->_hasOperations) { if (trx->_hasOperations) {
RollbackOperations(trx); RollbackOperations(trx);
FreeOperations(trx);
} }
res = UpdateTransactionStatus(trx, TRI_TRANSACTION_ABORTED); res = UpdateTransactionStatus(trx, TRI_TRANSACTION_ABORTED);
if (trx->_hasOperations) {
FreeOperations(trx);
}
} }
else { else {
res = TRI_ERROR_NO_ERROR; res = TRI_ERROR_NO_ERROR;