mirror of https://gitee.com/bigwinds/arangodb
fixed a memleak for barriers
This commit is contained in:
parent
5098792b4f
commit
bdf906ef89
|
@ -821,29 +821,32 @@ static v8::Handle<v8::Value> DocumentVocbaseCol (const bool useCollection,
|
||||||
|
|
||||||
assert(barrier != 0);
|
assert(barrier != 0);
|
||||||
|
|
||||||
|
bool freeBarrier = true;
|
||||||
|
|
||||||
v8::Handle<v8::Value> result;
|
v8::Handle<v8::Value> result;
|
||||||
TRI_doc_mptr_t document;
|
TRI_doc_mptr_t document;
|
||||||
res = trx.read(&document, key, true);
|
res = trx.read(&document, key, true);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
result = TRI_WrapShapedJson(resolver, col, &document, barrier);
|
result = TRI_WrapShapedJson(resolver, col, &document, barrier);
|
||||||
|
freeBarrier = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = trx.finish(res);
|
res = trx.finish(res);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR || document._key == 0 || document._data == 0) {
|
||||||
|
if (freeBarrier) {
|
||||||
|
TRI_FreeBarrier(barrier);
|
||||||
|
}
|
||||||
|
|
||||||
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(res, "document not found", true)));
|
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(res, "document not found", true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document._key == 0 || document._data == 0) {
|
|
||||||
TRI_FreeBarrier(barrier);
|
|
||||||
|
|
||||||
return scope.Close(v8::ThrowException(
|
|
||||||
TRI_CreateErrorObject(TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND,
|
|
||||||
"document not found")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rid != 0 && document._rid != rid) {
|
if (rid != 0 && document._rid != rid) {
|
||||||
|
if (freeBarrier) {
|
||||||
|
TRI_FreeBarrier(barrier);
|
||||||
|
}
|
||||||
|
|
||||||
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(TRI_ERROR_ARANGO_CONFLICT, "revision not found")));
|
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(TRI_ERROR_ARANGO_CONFLICT, "revision not found")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ bool TRI_IsValidMarkerDatafile (TRI_df_marker_t* const marker) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marker->_size >= (TRI_voc_size_t) (256 * 1024 * 1024)) {
|
if (marker->_size >= (TRI_voc_size_t) TRI_MARKER_MAXIMAL_SIZE) {
|
||||||
// a single marker bigger than 256 MB seems unreasonable
|
// a single marker bigger than 256 MB seems unreasonable
|
||||||
// note: this is an arbitrary limit
|
// note: this is an arbitrary limit
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -114,6 +114,12 @@ extern "C" {
|
||||||
|
|
||||||
#define TRI_DF_BLOCK_ALIGNMENT (8)
|
#define TRI_DF_BLOCK_ALIGNMENT (8)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief maximum size of a single marker (in bytes)
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define TRI_MARKER_MAXIMAL_SIZE (256 * 1024 * 1024)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -206,11 +206,20 @@ extern size_t PageSize;
|
||||||
#define TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE (1024 * 1024 * 32)
|
#define TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE (1024 * 1024 * 32)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief minimal collection journal size
|
/// @brief minimal collection journal size (for testing, we allow very small
|
||||||
|
/// file sizes in maintainer mode)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
|
|
||||||
|
#define TRI_JOURNAL_MINIMAL_SIZE (16 * 1024)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#define TRI_JOURNAL_MINIMAL_SIZE (1024 * 1024)
|
#define TRI_JOURNAL_MINIMAL_SIZE (1024 * 1024)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief journal overhead
|
/// @brief journal overhead
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -148,7 +148,25 @@ function CollectionSuiteErrorHandling () {
|
||||||
catch (err) {
|
catch (err) {
|
||||||
assertEqual(ERRORS.ERROR_ARANGO_ILLEGAL_NAME.code, err.errorNum);
|
assertEqual(ERRORS.ERROR_ARANGO_ILLEGAL_NAME.code, err.errorNum);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief creating with too small journal size
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testErrorInvalidJournalSize : function () {
|
||||||
|
var cn = "example";
|
||||||
|
|
||||||
|
db._drop(cn);
|
||||||
|
try {
|
||||||
|
db._create(cn, { waitForSync : false, journalSize : 1024 });
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
assertEqual(ERRORS.ERROR_BAD_PARAMETER.code, err.errorNum);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,6 +393,7 @@ function CollectionSuite () {
|
||||||
|
|
||||||
assertEqual(false, p.waitForSync);
|
assertEqual(false, p.waitForSync);
|
||||||
assertEqual(false, p.isVolatile);
|
assertEqual(false, p.isVolatile);
|
||||||
|
assertEqual(1048576, p.journalSize);
|
||||||
|
|
||||||
db._drop(cn);
|
db._drop(cn);
|
||||||
},
|
},
|
||||||
|
@ -399,14 +418,7 @@ function CollectionSuite () {
|
||||||
|
|
||||||
assertEqual(true, p.waitForSync);
|
assertEqual(true, p.waitForSync);
|
||||||
assertEqual(false, p.isVolatile);
|
assertEqual(false, p.isVolatile);
|
||||||
|
assertEqual(1048576, p.journalSize);
|
||||||
if (p.journalSize < 1024 * 1024) {
|
|
||||||
fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1024 * 1025 < p.journalSize) {
|
|
||||||
fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
db._drop(cn);
|
db._drop(cn);
|
||||||
},
|
},
|
||||||
|
@ -430,6 +442,7 @@ function CollectionSuite () {
|
||||||
var p = c1.properties();
|
var p = c1.properties();
|
||||||
|
|
||||||
assertEqual(true, p.isVolatile);
|
assertEqual(true, p.isVolatile);
|
||||||
|
assertEqual(1048576, p.journalSize);
|
||||||
db._drop(cn);
|
db._drop(cn);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue