1
0
Fork 0

small mods

This commit is contained in:
Jan Steemann 2013-02-12 18:16:23 +01:00
parent 052ae2f76f
commit 8365c4294c
11 changed files with 157 additions and 50 deletions

View File

@ -271,6 +271,8 @@ bool RestDocumentHandler::createDocument () {
"'collection' is missing, expecting " + DOCUMENT_PATH + "?collection=<identifier>");
return false;
}
const bool waitForSync = extractWaitForSync();
// auto-ptr that will free JSON data when scope is left
ResourceHolder holder;
@ -284,6 +286,7 @@ bool RestDocumentHandler::createDocument () {
return false;
}
// find and load collection given by name or identifier
SingleCollectionWriteTransaction<StandaloneTransaction<RestTransactionContext>, 1> trx(_vocbase, _resolver, collection);
@ -300,7 +303,7 @@ bool RestDocumentHandler::createDocument () {
const TRI_voc_cid_t cid = trx.cid();
TRI_doc_mptr_t* document = 0;
res = trx.createDocument(&document, json, extractWaitForSync());
res = trx.createDocument(&document, json, waitForSync, true);
res = trx.finish(res);
// .............................................................................

View File

@ -209,7 +209,7 @@ bool RestEdgeHandler::createDocument () {
// will hold the result
TRI_doc_mptr_t* document = 0;
res = trx.createEdge(&document, json, extractWaitForSync(), &edge);
res = trx.createEdge(&document, json, extractWaitForSync(), &edge, true);
res = trx.finish(res);
// .............................................................................

View File

@ -231,23 +231,24 @@ bool RestImportHandler::createByDocumentsLines () {
return false;
}
size_t start = 0;
size_t next = 0;
trx.lockWrite();
const char* ptr = _request->body();
const char* end = ptr + _request->bodySize();
string line;
string body(_request->body(), _request->bodySize());
while (ptr < end) {
const char* pos = strchr(ptr, '\n');
while (next != string::npos && start < body.size()) {
next = body.find('\n', start);
if (next == string::npos) {
line = body.substr(start);
if (pos == 0) {
line.assign(ptr, (size_t) (end - ptr));
ptr = end;
}
else {
line = body.substr(start, next - start);
start = next + 1;
line.assign(ptr, (size_t) (pos - ptr));
ptr = pos + 1;
}
StringUtils::trimInPlace(line, "\r\n\t ");
if (line.length() == 0) {
++numEmpty;
@ -260,7 +261,8 @@ bool RestImportHandler::createByDocumentsLines () {
// now save the document
TRI_doc_mptr_t* document = 0;
res = trx.createDocument(&document, values, forceSync);
// do not acquire an extra lock
res = trx.createDocument(&document, values, forceSync, false);
if (res == TRI_ERROR_NO_ERROR) {
++numCreated;
}
@ -389,7 +391,7 @@ bool RestImportHandler::createByDocumentsList () {
// now save the document
TRI_doc_mptr_t* document = 0;
res = trx.createDocument(&document, values, forceSync);
res = trx.createDocument(&document, values, forceSync, true);
if (res == TRI_ERROR_NO_ERROR) {
++numCreated;
}
@ -569,7 +571,7 @@ bool RestImportHandler::createByKeyValueList () {
// now save the document
TRI_doc_mptr_t* document = 0;
res = trx.createDocument(&document, json, forceSync);
res = trx.createDocument(&document, json, forceSync, true);
if (res == TRI_ERROR_NO_ERROR) {
++numCreated;

View File

@ -194,6 +194,7 @@ void RestVocbaseBaseHandler::generate20x (const HttpResponse::HttpResponseCode r
TRI_voc_key_t key,
TRI_voc_rid_t rid) {
const string handle = DocumentHelper::assembleDocumentId(collectionName, key);
const string rev = StringUtils::itoa(rid);
_response = createResponse(responseCode);
_response->setContentType("application/json; charset=utf-8");
@ -201,7 +202,7 @@ void RestVocbaseBaseHandler::generate20x (const HttpResponse::HttpResponseCode r
if (responseCode != HttpResponse::OK) {
// 200 OK is sent is case of delete or update.
// in these cases we do not return etag nor location
_response->setHeader("ETag", "\"" + StringUtils::itoa(rid) + "\"");
_response->setHeader("ETag", "\"" + rev + "\"");
// handle does not need to be RFC 2047-encoded
_response->setHeader("location", DOCUMENT_PATH + "/" + handle);
}
@ -209,9 +210,9 @@ void RestVocbaseBaseHandler::generate20x (const HttpResponse::HttpResponseCode r
// _id and _key are safe and do not need to be JSON-encoded
_response->body()
.appendText("{\"error\":false,\"_id\":\"")
.appendText(handle.c_str())
.appendText(handle)
.appendText("\",\"_rev\":\"")
.appendText(StringUtils::itoa(rid))
.appendText(rev)
.appendText("\",\"_key\":\"")
.appendText(key)
.appendText("\"}");

View File

@ -142,7 +142,8 @@ namespace triagens {
int createDocument (TRI_doc_mptr_t** mptr,
TRI_json_t const* json,
const bool forceSync) {
const bool forceSync,
const bool lock) {
if (_numWrites++ > N) {
return TRI_ERROR_TRANSACTION_INTERNAL;
}
@ -150,7 +151,7 @@ namespace triagens {
TRI_primary_collection_t* primary = this->primaryCollection();
_synchronous = forceSync || primary->base._info._waitForSync;
return this->createCollectionDocument(primary, TRI_DOC_MARKER_KEY_DOCUMENT, mptr, json, 0, forceSync);
return this->createCollectionDocument(primary, TRI_DOC_MARKER_KEY_DOCUMENT, mptr, json, 0, forceSync, lock);
}
////////////////////////////////////////////////////////////////////////////////
@ -160,7 +161,8 @@ namespace triagens {
int createEdge (TRI_doc_mptr_t** mptr,
TRI_json_t const* json,
bool forceSync,
void const* data) {
void const* data,
const bool lock) {
if (_numWrites++ > N) {
return TRI_ERROR_TRANSACTION_INTERNAL;
}
@ -168,7 +170,7 @@ namespace triagens {
TRI_primary_collection_t* primary = this->primaryCollection();
_synchronous = forceSync || primary->base._info._waitForSync;
return this->createCollectionDocument(primary, TRI_DOC_MARKER_KEY_EDGE, mptr, json, data, forceSync);
return this->createCollectionDocument(primary, TRI_DOC_MARKER_KEY_EDGE, mptr, json, data, forceSync, lock);
}
////////////////////////////////////////////////////////////////////////////////
@ -178,7 +180,8 @@ namespace triagens {
int createDocument (TRI_voc_key_t key,
TRI_doc_mptr_t** mptr,
TRI_shaped_json_t const* shaped,
bool forceSync) {
bool forceSync,
const bool lock) {
if (_numWrites++ > N) {
return TRI_ERROR_TRANSACTION_INTERNAL;
}
@ -186,7 +189,7 @@ namespace triagens {
TRI_primary_collection_t* primary = this->primaryCollection();
_synchronous = forceSync || primary->base._info._waitForSync;
return this->createCollectionShaped(primary, TRI_DOC_MARKER_KEY_DOCUMENT, key, mptr, shaped, 0, forceSync);
return this->createCollectionShaped(primary, TRI_DOC_MARKER_KEY_DOCUMENT, key, mptr, shaped, 0, forceSync, lock);
}
////////////////////////////////////////////////////////////////////////////////
@ -197,7 +200,8 @@ namespace triagens {
TRI_doc_mptr_t** mptr,
TRI_shaped_json_t const* shaped,
bool forceSync,
void const* data) {
void const* data,
const bool lock) {
if (_numWrites++ > N) {
return TRI_ERROR_TRANSACTION_INTERNAL;
}
@ -205,7 +209,7 @@ namespace triagens {
TRI_primary_collection_t* primary = this->primaryCollection();
_synchronous = forceSync || primary->base._info._waitForSync;
return this->createCollectionShaped(primary, TRI_DOC_MARKER_KEY_EDGE, key, mptr, shaped, data, forceSync);
return this->createCollectionShaped(primary, TRI_DOC_MARKER_KEY_EDGE, key, mptr, shaped, data, forceSync, lock);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -606,17 +606,22 @@ namespace triagens {
TRI_doc_mptr_t** mptr,
TRI_json_t const* json,
void const* data,
const bool forceSync) {
const bool forceSync,
const bool lock) {
TRI_doc_operation_context_t context;
TRI_InitContextPrimaryCollection(&context, primary, TRI_DOC_UPDATE_ERROR, forceSync);
// WRITE-LOCK START
this->lockExplicit(primary, TRI_TRANSACTION_WRITE);
if (lock) {
// WRITE-LOCK START
this->lockExplicit(primary, TRI_TRANSACTION_WRITE);
}
int res = primary->createJson(&context, markerType, mptr, json, data);
this->unlockExplicit(primary, TRI_TRANSACTION_WRITE);
// WRITE-LOCK END
if (lock) {
this->unlockExplicit(primary, TRI_TRANSACTION_WRITE);
// WRITE-LOCK END
}
return res;
}
@ -631,17 +636,22 @@ namespace triagens {
TRI_doc_mptr_t** mptr,
TRI_shaped_json_t const* shaped,
void const* data,
const bool forceSync) {
const bool forceSync,
const bool lock) {
TRI_doc_operation_context_t context;
TRI_InitContextPrimaryCollection(&context, primary, TRI_DOC_UPDATE_ERROR, forceSync);
// WRITE-LOCK START
this->lockExplicit(primary, TRI_TRANSACTION_WRITE);
if (lock) {
// WRITE-LOCK START
this->lockExplicit(primary, TRI_TRANSACTION_WRITE);
}
int res = primary->create(&context, markerType, mptr, shaped, data, key);
this->unlockExplicit(primary, TRI_TRANSACTION_WRITE);
// WRITE-LOCK END
if (lock) {
this->unlockExplicit(primary, TRI_TRANSACTION_WRITE);
// WRITE-LOCK END
}
return res;
}

View File

@ -993,7 +993,7 @@ static v8::Handle<v8::Value> SaveVocbaseCol (SingleCollectionWriteTransaction<Em
const bool forceSync = ExtractForceSync(argv, 2);
TRI_doc_mptr_t* document = 0;
int res = trx->createDocument(key, &document, shaped, forceSync);
int res = trx->createDocument(key, &document, shaped, forceSync, true);
res = trx->finish(res);
@ -1113,7 +1113,7 @@ static v8::Handle<v8::Value> SaveEdgeCol (SingleCollectionWriteTransaction<Embed
TRI_doc_mptr_t* document = 0;
int res = trx->createEdge(key, &document, shaped, forceSync, &edge);
int res = trx->createEdge(key, &document, shaped, forceSync, &edge, true);
res = trx->finish(res);
if (res != TRI_ERROR_NO_ERROR) {
@ -4415,12 +4415,15 @@ static v8::Handle<v8::Value> JS_FiguresVocbaseCol (v8::Arguments const& argv) {
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(res, "cannot fetch figures", true)));
}
// READ-LOCK start
trx.lockRead();
TRI_primary_collection_t* primary = collection->_collection;
TRI_doc_collection_info_t* info = primary->figures(primary);
res = trx.finish(res);
// READ-LOCK end
if (res != TRI_ERROR_NO_ERROR) {
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(res, "cannot fetch figures", true)));
}
@ -5126,11 +5129,13 @@ static v8::Handle<v8::Value> JS_RevisionVocbaseCol (v8::Arguments const& argv) {
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(res, "cannot fetch revision", true)));
}
// READ-LOCK start
trx.lockRead();
TRI_primary_collection_t* primary = collection->_collection;
TRI_voc_rid_t rid = primary->base._info._rid;
trx.finish(res);
// READ-LOCK end
return scope.Close(V8RevisionId(rid));
}

View File

@ -50,17 +50,20 @@
/// @brief hash a collection
////////////////////////////////////////////////////////////////////////////////
#if 0
static uint64_t HashCollection (TRI_associative_pointer_t* array,
void const* element) {
TRI_transaction_collection_global_t* collection = (TRI_transaction_collection_global_t*) element;
return TRI_FnvHashPointer((void const*) &(collection->_cid), sizeof(TRI_transaction_cid_t));
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief comparison function used to determine collection equality
////////////////////////////////////////////////////////////////////////////////
#if 0
static bool IsEqualCollectionId (TRI_associative_pointer_t* array,
void const* key,
void const* element) {
@ -68,11 +71,13 @@ static bool IsEqualCollectionId (TRI_associative_pointer_t* array,
return *((TRI_transaction_cid_t*) key) == collection->_cid;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the transaction as a string
////////////////////////////////////////////////////////////////////////////////
#if 0
static const char* TypeString (const TRI_transaction_type_e type) {
switch (type) {
case TRI_TRANSACTION_READ:
@ -84,11 +89,13 @@ static const char* TypeString (const TRI_transaction_type_e type) {
assert(false);
return "unknown";
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief return the status of the transaction as a string
////////////////////////////////////////////////////////////////////////////////
#if 0
static const char* StatusString (const TRI_transaction_status_e status) {
switch (status) {
case TRI_TRANSACTION_UNDEFINED:
@ -110,24 +117,28 @@ static const char* StatusString (const TRI_transaction_status_e status) {
assert(false);
return "unknown";
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief generate a transaction id
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static TRI_transaction_local_id_t NextLocalTransactionId (TRI_transaction_context_t* const context) {
TRI_transaction_local_id_t id;
id = ++context->_id._localId;
return (TRI_transaction_local_id_t) id;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief register a transaction in the global transactions list
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static int InsertTransactionList (TRI_transaction_list_t* const list,
TRI_transaction_t* const trx) {
const TRI_transaction_local_id_t id = trx->_id._localId;
@ -146,6 +157,7 @@ static int InsertTransactionList (TRI_transaction_list_t* const list,
return res;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief locate a transaction in the global transactions list using a
@ -153,6 +165,7 @@ static int InsertTransactionList (TRI_transaction_list_t* const list,
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static TRI_transaction_list_entry_t* FindTransactionList (const TRI_transaction_list_t* const list,
const TRI_transaction_local_id_t id,
size_t* position) {
@ -195,12 +208,14 @@ static TRI_transaction_list_entry_t* FindTransactionList (const TRI_transaction_
}
}
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief remove a transaction from the global transactions list
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static int RemoveTransactionList (TRI_transaction_list_t* const list,
const TRI_transaction_local_id_t id) {
TRI_transaction_list_entry_t* entry;
@ -229,12 +244,14 @@ static int RemoveTransactionList (TRI_transaction_list_t* const list,
return TRI_ERROR_NO_ERROR;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief remove a transaction from the global transactions list
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static int UpdateTransactionList (TRI_transaction_list_t* const list,
const TRI_transaction_local_id_t id,
const TRI_transaction_status_e status) {
@ -266,29 +283,35 @@ static int UpdateTransactionList (TRI_transaction_list_t* const list,
return TRI_ERROR_NO_ERROR;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief initialise a transactions list
////////////////////////////////////////////////////////////////////////////////
#if 0
static void InitTransactionList (TRI_transaction_list_t* const list) {
TRI_InitVector(&list->_vector, TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_transaction_list_entry_t));
list->_numRunning = 0;
list->_numAborted = 0;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy a transactions list
////////////////////////////////////////////////////////////////////////////////
#if 0
static void DestroyTransactionList (TRI_transaction_list_t* const list) {
TRI_DestroyVector(&list->_vector);
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief dump the contents of a transaction list
////////////////////////////////////////////////////////////////////////////////
#if 0
static void DumpTransactionList (const TRI_transaction_list_t* const list) {
size_t i, n;
@ -301,11 +324,13 @@ static void DumpTransactionList (const TRI_transaction_list_t* const list) {
StatusString(entry->_status));
}
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief create a collection for the global context
////////////////////////////////////////////////////////////////////////////////
#if 0
TRI_transaction_collection_global_t* CreateCollectionGlobalInstance (const TRI_transaction_collection_t* const collection) {
TRI_transaction_collection_global_t* globalInstance;
@ -322,17 +347,20 @@ TRI_transaction_collection_global_t* CreateCollectionGlobalInstance (const TRI_t
return globalInstance;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief free a collection from the global context
////////////////////////////////////////////////////////////////////////////////
#if 0
void FreeCollectionGlobalInstance (TRI_transaction_collection_global_t* const globalInstance) {
DestroyTransactionList(&globalInstance->_writeTransactions);
TRI_DestroyMutex(&globalInstance->_writeLock);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, globalInstance);
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @}
@ -360,6 +388,7 @@ TRI_transaction_context_t* TRI_CreateTransactionContext (TRI_vocbase_t* const vo
return context;
}
#if 0
TRI_InitMutex(&context->_lock);
TRI_InitMutex(&context->_collectionLock);
@ -370,10 +399,11 @@ TRI_transaction_context_t* TRI_CreateTransactionContext (TRI_vocbase_t* const vo
HashCollection,
IsEqualCollectionId,
NULL);
// setup global transaction lists
InitTransactionList(&context->_readTransactions);
InitTransactionList(&context->_writeTransactions);
#endif
context->_vocbase = vocbase;
context->_id._localId = 0;
@ -387,6 +417,7 @@ TRI_transaction_context_t* TRI_CreateTransactionContext (TRI_vocbase_t* const vo
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeTransactionContext (TRI_transaction_context_t* const context) {
#if 0
uint32_t i, n;
// destroy global transaction lists
@ -406,8 +437,9 @@ void TRI_FreeTransactionContext (TRI_transaction_context_t* const context) {
TRI_DestroyAssociativePointer(&context->_collections);
// destroy mutexes
TRI_DestroyMutex(&context->_lock);
TRI_DestroyMutex(&context->_lock);
TRI_DestroyMutex(&context->_collectionLock);
#endif
TRI_Free(TRI_UNKNOWN_MEM_ZONE, context);
}
@ -432,6 +464,7 @@ void TRI_FreeTransactionContext (TRI_transaction_context_t* const context) {
void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* const context,
const TRI_transaction_cid_t cid) {
#if 0
TRI_transaction_collection_global_t* collection;
// start critical section -----------------------------------------
@ -446,6 +479,7 @@ void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* const co
if (collection != NULL) {
FreeCollectionGlobalInstance(collection);
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
@ -453,6 +487,7 @@ void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* const co
////////////////////////////////////////////////////////////////////////////////
void TRI_DumpTransactionContext (TRI_transaction_context_t* const context) {
#if 0
TRI_LockMutex(&context->_lock);
LOG_INFO("transaction context, last-id: %lu:%lu",
@ -474,6 +509,7 @@ void TRI_DumpTransactionContext (TRI_transaction_context_t* const context) {
DumpTransactionList(&context->_writeTransactions);
TRI_UnlockMutex(&context->_lock);
#endif
}
////////////////////////////////////////////////////////////////////////////////
@ -511,13 +547,16 @@ static TRI_transaction_collection_t* CreateCollection (const TRI_transaction_cid
collection->_cid = cid;
collection->_type = type;
collection->_collection = NULL;
#if 0
collection->_globalInstance = NULL;
collection->_globalLock = false;
#endif
collection->_locked = false;
#if 0
// initialise private copy of write transactions list
InitTransactionList(&collection->_writeTransactions);
#endif
return collection;
}
@ -528,7 +567,9 @@ static TRI_transaction_collection_t* CreateCollection (const TRI_transaction_cid
static void FreeCollection (TRI_transaction_collection_t* collection) {
assert(collection);
#if 0
DestroyTransactionList(&collection->_writeTransactions);
#endif
TRI_Free(TRI_UNKNOWN_MEM_ZONE, collection);
}
@ -592,6 +633,7 @@ static int UnlockCollection (TRI_transaction_collection_t* collection,
/// this function will create a global instance if it does not yet exist
////////////////////////////////////////////////////////////////////////////////
#if 0
static TRI_transaction_collection_global_t* GetGlobalCollection (TRI_transaction_context_t* const context,
const TRI_transaction_collection_t* const collection) {
TRI_transaction_collection_global_t* globalInstance;
@ -612,6 +654,7 @@ static TRI_transaction_collection_global_t* GetGlobalCollection (TRI_transaction
return globalInstance;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief use all participating collections of a transaction
@ -640,17 +683,21 @@ static int UseCollections (TRI_transaction_t* const trx) {
return TRI_errno();
}
#if 0
collection->_globalInstance = GetGlobalCollection(context, collection);
if (collection->_globalInstance == NULL) {
return TRI_ERROR_OUT_OF_MEMORY;
}
#endif
if (collection->_type == TRI_TRANSACTION_WRITE) {
LOG_DEBUG("acquiring write-lock on collection %llu", (unsigned long long) collection->_cid);
#if 0
// acquire write-lock on collection
TRI_LockMutex(&collection->_globalInstance->_writeLock);
collection->_globalLock = true;
#endif
}
if ((trx->_hints & (TRI_transaction_hint_t) TRI_TRANSACTION_HINT_IMPLICIT_LOCK) != 0) {
@ -692,6 +739,7 @@ static int ReleaseCollections (TRI_transaction_t* const trx) {
UnlockCollection(collection, collection->_type);
}
#if 0
if (collection->_type == TRI_TRANSACTION_WRITE && collection->_globalLock) {
LOG_DEBUG("releasing trx exclusive lock on collection %llu", (unsigned long long) collection->_cid);
@ -700,6 +748,7 @@ static int ReleaseCollections (TRI_transaction_t* const trx) {
collection->_globalLock = false;
}
#endif
// unuse collection
LOG_DEBUG("unusing collection %llu", (unsigned long long) collection->_cid);
@ -716,6 +765,7 @@ static int ReleaseCollections (TRI_transaction_t* const trx) {
/// collection transaction list
////////////////////////////////////////////////////////////////////////////////
#if 0
static int CloneTransactionList (TRI_transaction_list_t* const dest,
const TRI_transaction_list_t* const source) {
dest->_numRunning = source->_numRunning;
@ -723,6 +773,7 @@ static int CloneTransactionList (TRI_transaction_list_t* const dest,
return TRI_CopyDataVector(&dest->_vector, &source->_vector);
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief make private copies of other write-transactions for each collection
@ -730,6 +781,7 @@ static int CloneTransactionList (TRI_transaction_list_t* const dest,
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static int CopyWriteTransactions (TRI_transaction_t* const trx) {
size_t i, n;
@ -758,12 +810,14 @@ static int CopyWriteTransactions (TRI_transaction_t* const trx) {
return TRI_ERROR_NO_ERROR;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief remove a transaction from all collections' write transaction lists
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static int RemoveCollectionsWriteTransaction (TRI_transaction_t* const trx,
const TRI_transaction_local_id_t id) {
size_t i, n;
@ -793,6 +847,7 @@ static int RemoveCollectionsWriteTransaction (TRI_transaction_t* const trx,
return TRI_ERROR_NO_ERROR;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief update the status of a transaction in all participating collections'
@ -800,6 +855,7 @@ static int RemoveCollectionsWriteTransaction (TRI_transaction_t* const trx,
/// The context lock must be held when calling this function
////////////////////////////////////////////////////////////////////////////////
#if 0
static int UpdateCollectionsWriteTransaction (TRI_transaction_t* const trx,
const TRI_transaction_local_id_t id,
const TRI_transaction_status_e status) {
@ -830,6 +886,7 @@ static int UpdateCollectionsWriteTransaction (TRI_transaction_t* const trx,
return TRI_ERROR_NO_ERROR;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief update the status of a transaction
@ -837,15 +894,17 @@ static int UpdateCollectionsWriteTransaction (TRI_transaction_t* const trx,
static int UpdateTransactionStatus (TRI_transaction_t* const trx,
const TRI_transaction_status_e status) {
#if 0
const TRI_transaction_local_id_t id = trx->_id._localId;
TRI_transaction_context_t* context;
#endif
int res;
assert(trx->_status == TRI_TRANSACTION_RUNNING);
assert(status == TRI_TRANSACTION_COMMITTED ||
status == TRI_TRANSACTION_ABORTED ||
status == TRI_TRANSACTION_FINISHED);
#if 0
context = trx->_context;
// start critical section -----------------------------------------
@ -879,6 +938,9 @@ static int UpdateTransactionStatus (TRI_transaction_t* const trx,
TRI_UnlockMutex(&context->_lock);
// end critical section -----------------------------------------
#else
res = TRI_ERROR_NO_ERROR;
#endif
if (res == TRI_ERROR_NO_ERROR) {
trx->_status = status;
@ -892,12 +954,14 @@ static int UpdateTransactionStatus (TRI_transaction_t* const trx,
////////////////////////////////////////////////////////////////////////////////
static int RegisterTransaction (TRI_transaction_t* const trx) {
#if 0
TRI_transaction_context_t* context;
TRI_transaction_list_t* list;
#endif
int res;
assert(trx->_status == TRI_TRANSACTION_CREATED);
#if 0
context = trx->_context;
trx->_status = TRI_TRANSACTION_RUNNING;
@ -925,7 +989,9 @@ static int RegisterTransaction (TRI_transaction_t* const trx) {
TRI_UnlockMutex(&context->_lock);
// end critical section -----------------------------------------
#else
res = TRI_ERROR_NO_ERROR;
#endif
return res;
}
@ -1106,14 +1172,17 @@ bool TRI_IsMultiCollectionWriteTransaction (const TRI_transaction_t* const trx)
/// @brief return the local id of a transaction
////////////////////////////////////////////////////////////////////////////////
#if 0
TRI_transaction_local_id_t TRI_LocalIdTransaction (const TRI_transaction_t* const trx) {
return trx->_id._localId;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief dump information about a transaction
////////////////////////////////////////////////////////////////////////////////
#if 0
void TRI_DumpTransaction (TRI_transaction_t* const trx) {
size_t i, n;
@ -1140,6 +1209,7 @@ void TRI_DumpTransaction (TRI_transaction_t* const trx) {
}
}
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief check if a collection is contained in a transaction and return it

View File

@ -141,22 +141,26 @@ TRI_transaction_status_e;
/// @brief an entry in the transactions list
////////////////////////////////////////////////////////////////////////////////
#if 0
typedef struct TRI_transaction_list_entry_s {
TRI_transaction_local_id_t _id;
TRI_transaction_status_e _status;
}
TRI_transaction_list_entry_t;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief transaction list typedef
////////////////////////////////////////////////////////////////////////////////
#if 0
typedef struct TRI_transaction_list_s {
TRI_vector_t _vector; // vector containing trx_list_entry_t
size_t _numRunning; // number of currently running trx
size_t _numAborted; // number of already aborted trx
}
TRI_transaction_list_t;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @}
@ -182,13 +186,13 @@ TRI_transaction_list_t;
typedef struct TRI_transaction_context_s {
TRI_transaction_id_t _id; // last transaction id assigned
#if 0
TRI_mutex_t _lock; // lock used to serialize starting/stopping transactions
TRI_mutex_t _collectionLock; // lock used when accessing _collections
TRI_mutex_t _creatorLock; // lock used when accessing _creators
TRI_transaction_list_t _readTransactions; // global list of currently ongoing read transactions
TRI_transaction_list_t _writeTransactions; // global list of currently ongoing write transactions
TRI_associative_pointer_t _collections; // list of collections (TRI_transaction_collection_global_t)
TRI_associative_pointer_t _creators; // hash of transaction creator pointers (used to prevent nested transactions)
#endif
struct TRI_vocbase_s* _vocbase; // pointer to vocbase
}
TRI_transaction_context_t;
@ -197,12 +201,14 @@ TRI_transaction_context_t;
/// @brief global instance of a collection in the transaction system
////////////////////////////////////////////////////////////////////////////////
#if 0
typedef struct TRI_transaction_collection_global_s {
TRI_transaction_cid_t _cid; // collection id
TRI_transaction_list_t _writeTransactions; // list of write-transactions currently going on for the collection
TRI_mutex_t _writeLock; // write lock for the collection, used to serialize writes on the same collection
}
TRI_transaction_collection_global_t;
#endif
////////////////////////////////////////////////////////////////////////////////
/// @}
@ -256,7 +262,9 @@ void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* const,
/// @brief dump transaction context data
////////////////////////////////////////////////////////////////////////////////
#if 0
void TRI_DumpTransactionContext (TRI_transaction_context_t* const);
#endif
////////////////////////////////////////////////////////////////////////////////
/// @}
@ -282,10 +290,14 @@ void TRI_DumpTransactionContext (TRI_transaction_context_t* const);
typedef struct TRI_transaction_collection_s {
TRI_transaction_cid_t _cid; // collection id
TRI_transaction_type_e _type; // access type (read|write)
#if 0
TRI_transaction_list_t _writeTransactions; // private copy of other write transactions at transaction start
#endif
struct TRI_vocbase_col_s* _collection; // vocbase collection pointer
#if 0
TRI_transaction_collection_global_t* _globalInstance; // pointer to the global instance of the collection in the trx system
bool _globalLock; // global collection lock flag (used for write transactions)
#endif
bool _locked; // collection lock flag
}
TRI_transaction_collection_t;
@ -383,7 +395,9 @@ TRI_transaction_local_id_t TRI_LocalIdTransaction (const TRI_transaction_t* cons
/// @brief dump information about a transaction
////////////////////////////////////////////////////////////////////////////////
#if 0
void TRI_DumpTransaction (TRI_transaction_t* const);
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief check if a collection is contained in a transaction and return it

View File

@ -94,8 +94,8 @@ typedef int64_t TRI_msec_t;
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_blob_s {
uint32_t length;
char* data;
uint32_t length;
}
TRI_blob_t;

View File

@ -2398,8 +2398,6 @@ TRI_json_t* TRI_Json2String (TRI_memory_zone_t* zone, char const* text, char** e
struct yyguts_t * yyg;
yyscan_t scanner;
object = 0;
tri_jsp_lex_init(&scanner);
yyg = (struct yyguts_t*) scanner;