mirror of https://gitee.com/bigwinds/arangodb
Merge pull request #216 from jsteemann/issue213
possible implementation for issue #213
This commit is contained in:
commit
f7c990ce1a
|
@ -240,8 +240,11 @@ bool RestDocumentHandler::createDocument () {
|
|||
return false;
|
||||
}
|
||||
|
||||
// extract the cid
|
||||
bool found;
|
||||
char const* forceStr = _request->value("waitForSync", found);
|
||||
bool forceSync = found ? StringUtils::boolean(forceStr) : false;
|
||||
|
||||
// extract the cid
|
||||
char const* collection = _request->value("collection", found);
|
||||
|
||||
if (! found || *collection == '\0') {
|
||||
|
@ -286,7 +289,7 @@ bool RestDocumentHandler::createDocument () {
|
|||
|
||||
WriteTransaction trx(&ca);
|
||||
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_DOCUMENT, json, 0, reuseId, false);
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_DOCUMENT, json, 0, reuseId, false, forceSync);
|
||||
|
||||
trx.end();
|
||||
|
||||
|
@ -728,6 +731,10 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool found;
|
||||
char const* forceStr = _request->value("waitForSync", found);
|
||||
bool forceSync = found ? StringUtils::boolean(forceStr) : false;
|
||||
|
||||
// split the document reference
|
||||
string collection = suffix[0];
|
||||
string didStr = suffix[1];
|
||||
|
@ -775,7 +782,6 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
|
|||
if (isPatch) {
|
||||
// patching an existing document
|
||||
bool nullMeansRemove;
|
||||
bool found;
|
||||
|
||||
char const* valueStr = _request->value("keepNull", found);
|
||||
if (!found || StringUtils::boolean(valueStr)) {
|
||||
|
@ -798,7 +804,7 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
|
|||
TRI_FreeJson(shaper->_memoryZone, old);
|
||||
|
||||
if (patchedJson != 0) {
|
||||
mptr = trx.primary()->updateJson(trx.primary(), patchedJson, did, revision, &rid, policy, false);
|
||||
mptr = trx.primary()->updateJson(trx.primary(), patchedJson, did, revision, &rid, policy, false, forceSync);
|
||||
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, patchedJson);
|
||||
}
|
||||
|
@ -806,7 +812,7 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
|
|||
}
|
||||
else {
|
||||
// replacing an existing document
|
||||
mptr = trx.primary()->updateJson(trx.primary(), json, did, revision, &rid, policy, false);
|
||||
mptr = trx.primary()->updateJson(trx.primary(), json, did, revision, &rid, policy, false, forceSync);
|
||||
}
|
||||
|
||||
trx.end();
|
||||
|
@ -913,6 +919,10 @@ bool RestDocumentHandler::deleteDocument () {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool found;
|
||||
char const* forceStr = _request->value("waitForSync", found);
|
||||
bool forceSync = found ? StringUtils::boolean(forceStr) : false;
|
||||
|
||||
// split the document reference
|
||||
string collection = suffix[0];
|
||||
string didStr = suffix[1];
|
||||
|
@ -953,7 +963,7 @@ bool RestDocumentHandler::deleteDocument () {
|
|||
WriteTransaction trx(&ca);
|
||||
|
||||
// unlocking is performed in destroy()
|
||||
res = trx.primary()->destroy(trx.primary(), did, revision, &rid, policy, false);
|
||||
res = trx.primary()->destroy(trx.primary(), did, revision, &rid, policy, false, forceSync);
|
||||
|
||||
trx.end();
|
||||
|
||||
|
|
|
@ -108,11 +108,14 @@ bool RestEdgeHandler::createDocument () {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool found;
|
||||
char const* forceStr = _request->value("waitForSync", found);
|
||||
bool forceSync = found ? StringUtils::boolean(forceStr) : false;
|
||||
|
||||
// edge
|
||||
TRI_document_edge_t edge;
|
||||
|
||||
// extract the from
|
||||
bool found;
|
||||
char const* from = _request->value("from", found);
|
||||
|
||||
if (! found || *from == '\0') {
|
||||
|
@ -198,7 +201,7 @@ bool RestEdgeHandler::createDocument () {
|
|||
|
||||
WriteTransaction trx(&ca);
|
||||
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_EDGE, json, &edge, reuseId, false);
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_EDGE, json, &edge, reuseId, false, forceSync);
|
||||
|
||||
trx.end();
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ bool RestImportHandler::createByArray () {
|
|||
size_t numCreated = 0;
|
||||
size_t numError = 0;
|
||||
size_t numEmpty = 0;
|
||||
const bool forceSync = false;
|
||||
|
||||
vector<string> const& suffix = _request->suffix();
|
||||
|
||||
|
@ -243,7 +244,7 @@ bool RestImportHandler::createByArray () {
|
|||
|
||||
if (values) {
|
||||
// now save the document
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_DOCUMENT, values, 0, reuseId, false);
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_DOCUMENT, values, 0, reuseId, false, forceSync);
|
||||
if (mptr._did != 0) {
|
||||
++numCreated;
|
||||
}
|
||||
|
@ -287,6 +288,7 @@ bool RestImportHandler::createByList () {
|
|||
size_t numCreated = 0;
|
||||
size_t numError = 0;
|
||||
size_t numEmpty = 0;
|
||||
const bool forceSync = false;
|
||||
|
||||
vector<string> const& suffix = _request->suffix();
|
||||
|
||||
|
@ -426,7 +428,7 @@ bool RestImportHandler::createByList () {
|
|||
}
|
||||
|
||||
// now save the document
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_DOCUMENT, json, 0, reuseId, false);
|
||||
TRI_doc_mptr_t const mptr = trx.primary()->createJson(trx.primary(), TRI_DOC_MARKER_DOCUMENT, json, 0, reuseId, false, forceSync);
|
||||
if (mptr._did != 0) {
|
||||
++numCreated;
|
||||
}
|
||||
|
|
|
@ -648,7 +648,7 @@ static v8::Handle<v8::Value> ReplaceVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
|
||||
return scope.Close(v8::ThrowException(
|
||||
TRI_CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: replace(<document>, <data>, <overwrite>)")));
|
||||
"usage: replace(<document>, <data>, <overwrite>, <waitForSync>)")));
|
||||
}
|
||||
|
||||
TRI_voc_did_t did;
|
||||
|
@ -689,6 +689,11 @@ static v8::Handle<v8::Value> ReplaceVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
}
|
||||
}
|
||||
|
||||
bool forceSync = false;
|
||||
if (4 == argv.Length()) {
|
||||
forceSync = TRI_ObjectToBoolean(argv[3]);
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
// inside a write transaction
|
||||
// .............................................................................
|
||||
|
@ -696,7 +701,7 @@ static v8::Handle<v8::Value> ReplaceVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
primary->beginWrite(primary);
|
||||
|
||||
TRI_voc_rid_t oldRid = 0;
|
||||
TRI_doc_mptr_t mptr = primary->update(primary, shaped, did, rid, &oldRid, policy, true);
|
||||
TRI_doc_mptr_t mptr = primary->update(primary, shaped, did, rid, &oldRid, policy, true, forceSync);
|
||||
|
||||
// .............................................................................
|
||||
// outside a write transaction
|
||||
|
@ -749,17 +754,17 @@ static v8::Handle<v8::Value> SaveVocbaseCol (TRI_vocbase_col_t const* collection
|
|||
|
||||
TRI_primary_collection_t* primary = collection->_collection;
|
||||
|
||||
if (argv.Length() != 1 && argv.Length() != 3) {
|
||||
if (argv.Length() != 1 && argv.Length() != 3 && argv.Length() != 4) {
|
||||
return scope.Close(v8::ThrowException(
|
||||
TRI_CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: save(<data>)")));
|
||||
"usage: save(<data>, <did>, <rid>, <waitForSync>)")));
|
||||
}
|
||||
|
||||
// set document id and revision id
|
||||
TRI_voc_did_t did = 0;
|
||||
TRI_voc_rid_t rid = 0;
|
||||
|
||||
if (argv.Length() == 3) {
|
||||
if (3 <= argv.Length()) {
|
||||
// use existing document and revision ids
|
||||
// this functionality is used when importing documents from another server etc.
|
||||
// the functionality is not advertised
|
||||
|
@ -767,6 +772,11 @@ static v8::Handle<v8::Value> SaveVocbaseCol (TRI_vocbase_col_t const* collection
|
|||
rid = TRI_ObjectToUInt64(argv[2]);
|
||||
}
|
||||
|
||||
bool forceSync = false;
|
||||
if (4 == argv.Length()) {
|
||||
forceSync = TRI_ObjectToBoolean(argv[3]);
|
||||
}
|
||||
|
||||
TRI_shaped_json_t* shaped = TRI_ShapedJsonV8Object(argv[0], primary->_shaper);
|
||||
|
||||
if (shaped == 0) {
|
||||
|
@ -782,7 +792,7 @@ static v8::Handle<v8::Value> SaveVocbaseCol (TRI_vocbase_col_t const* collection
|
|||
primary->beginWrite(primary);
|
||||
|
||||
// the lock is freed in create
|
||||
TRI_doc_mptr_t mptr = primary->create(primary, TRI_DOC_MARKER_DOCUMENT, shaped, 0, did, rid, true);
|
||||
TRI_doc_mptr_t mptr = primary->create(primary, TRI_DOC_MARKER_DOCUMENT, shaped, 0, did, rid, true, forceSync);
|
||||
|
||||
// .............................................................................
|
||||
// outside a write transaction
|
||||
|
@ -827,17 +837,17 @@ static v8::Handle<v8::Value> SaveEdgeCol (TRI_vocbase_col_t const* collection,
|
|||
|
||||
TRI_primary_collection_t* primary = collection->_collection;
|
||||
|
||||
if (argv.Length() != 3 && argv.Length() != 5) {
|
||||
if (argv.Length() != 3 && argv.Length() != 5 && argv.Length() != 6) {
|
||||
return scope.Close(v8::ThrowException(
|
||||
TRI_CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: save(<from>, <to>, <data>)")));
|
||||
"usage: save(<from>, <to>, <data>, <did>, <rid>, <waitForSync>)")));
|
||||
}
|
||||
|
||||
// set document id and revision id
|
||||
TRI_voc_did_t did = 0;
|
||||
TRI_voc_rid_t rid = 0;
|
||||
|
||||
if (argv.Length() == 5) {
|
||||
if (5 <= argv.Length()) {
|
||||
// use existing document and revision ids
|
||||
// this functionality is used when importing documents from another server etc.
|
||||
// the functionality is not advertised
|
||||
|
@ -845,6 +855,11 @@ static v8::Handle<v8::Value> SaveEdgeCol (TRI_vocbase_col_t const* collection,
|
|||
rid = TRI_ObjectToUInt64(argv[4]);
|
||||
}
|
||||
|
||||
bool forceSync = false;
|
||||
if (6 == argv.Length()) {
|
||||
forceSync = TRI_ObjectToBoolean(argv[5]);
|
||||
}
|
||||
|
||||
TRI_document_edge_t edge;
|
||||
|
||||
edge._fromCid = collection->_cid;
|
||||
|
@ -901,7 +916,7 @@ static v8::Handle<v8::Value> SaveEdgeCol (TRI_vocbase_col_t const* collection,
|
|||
|
||||
primary->beginWrite(primary);
|
||||
|
||||
TRI_doc_mptr_t mptr = primary->create(primary, TRI_DOC_MARKER_EDGE, shaped, &edge, did, rid, true);
|
||||
TRI_doc_mptr_t mptr = primary->create(primary, TRI_DOC_MARKER_EDGE, shaped, &edge, did, rid, true, forceSync);
|
||||
|
||||
// .............................................................................
|
||||
// outside a write transaction
|
||||
|
@ -937,12 +952,12 @@ static v8::Handle<v8::Value> UpdateVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
v8g = (TRI_v8_global_t*) v8::Isolate::GetCurrent()->GetData();
|
||||
|
||||
// check the arguments
|
||||
if (argv.Length() < 2) {
|
||||
if (2 > argv.Length()) {
|
||||
TRI_ReleaseCollection(collection);
|
||||
|
||||
return scope.Close(v8::ThrowException(
|
||||
TRI_CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: update(<document>, <data>, <overwrite>, <keepnull>)")));
|
||||
"usage: update(<document>, <data>, <overwrite>, <keepnull>, <waitForSync>)")));
|
||||
}
|
||||
|
||||
TRI_voc_did_t did;
|
||||
|
@ -993,6 +1008,11 @@ static v8::Handle<v8::Value> UpdateVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
nullMeansRemove = false;
|
||||
}
|
||||
|
||||
bool forceSync = false;
|
||||
if (5 == argv.Length()) {
|
||||
forceSync = TRI_ObjectToBoolean(argv[4]);
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
// inside a write transaction
|
||||
// .............................................................................
|
||||
|
@ -1013,7 +1033,7 @@ static v8::Handle<v8::Value> UpdateVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
TRI_FreeJson(primary->_shaper->_memoryZone, old);
|
||||
|
||||
if (patchedJson != 0) {
|
||||
mptr = primary->updateJson(primary, patchedJson, did, rid, &oldRid, policy, true);
|
||||
mptr = primary->updateJson(primary, patchedJson, did, rid, &oldRid, policy, true, forceSync);
|
||||
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, patchedJson);
|
||||
}
|
||||
|
@ -1055,7 +1075,7 @@ static v8::Handle<v8::Value> DeleteVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
if (argv.Length() < 1) {
|
||||
TRI_ReleaseCollection(collection);
|
||||
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: delete(<document>, <overwrite>)")));
|
||||
"usage: delete(<document>, <overwrite>, <waitForSync>)")));
|
||||
}
|
||||
|
||||
TRI_voc_did_t did;
|
||||
|
@ -1085,6 +1105,11 @@ static v8::Handle<v8::Value> DeleteVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
}
|
||||
}
|
||||
|
||||
bool forceSync = false;
|
||||
if (3 == argv.Length()) {
|
||||
forceSync = TRI_ObjectToBoolean(argv[2]);
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
// inside a write transaction
|
||||
// .............................................................................
|
||||
|
@ -1092,7 +1117,7 @@ static v8::Handle<v8::Value> DeleteVocbaseCol (TRI_vocbase_t* vocbase,
|
|||
TRI_primary_collection_t* primary = collection->_collection;
|
||||
TRI_voc_rid_t oldRid;
|
||||
|
||||
int res = primary->destroyLock(primary, did, rid, &oldRid, policy);
|
||||
int res = primary->destroyLock(primary, did, rid, &oldRid, policy, forceSync);
|
||||
|
||||
// .............................................................................
|
||||
// outside a write transaction
|
||||
|
@ -4147,7 +4172,12 @@ static v8::Handle<v8::Value> JS_StatusVocbaseCol (v8::Arguments const& argv) {
|
|||
|
||||
static v8::Handle<v8::Value> JS_TruncateVocbaseCol (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
|
||||
bool forceSync = false;
|
||||
if (1 == argv.Length()) {
|
||||
forceSync = TRI_ObjectToBoolean(argv[0]);
|
||||
}
|
||||
|
||||
// extract and use the simple collection
|
||||
v8::Handle<v8::Object> err;
|
||||
TRI_vocbase_col_t const* collection;
|
||||
|
@ -4184,7 +4214,7 @@ static v8::Handle<v8::Value> JS_TruncateVocbaseCol (v8::Arguments const& argv) {
|
|||
for (size_t i = 0; i < documents._length; ++i) {
|
||||
TRI_doc_mptr_t const* d = (TRI_doc_mptr_t const*) documents._buffer[i];
|
||||
|
||||
int res = primary->destroy(primary, d->_did, d->_rid, &oldRid, policy, false);
|
||||
int res = primary->destroy(primary, d->_did, d->_rid, &oldRid, policy, false, forceSync);
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// an error occurred, but we simply go on because truncate should remove all documents
|
||||
}
|
||||
|
|
|
@ -62,21 +62,24 @@ static TRI_doc_mptr_t UpdateDocument (TRI_document_collection_t* collection,
|
|||
TRI_doc_update_policy_e policy,
|
||||
TRI_df_marker_t** result,
|
||||
bool release,
|
||||
bool allowRollback);
|
||||
bool allowRollback,
|
||||
bool forceSync);
|
||||
|
||||
static int DeleteDocument (TRI_document_collection_t* collection,
|
||||
TRI_doc_deletion_marker_t* marker,
|
||||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool release);
|
||||
bool release,
|
||||
bool forceSync);
|
||||
|
||||
static int DeleteShapedJson (TRI_primary_collection_t* doc,
|
||||
TRI_voc_did_t did,
|
||||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool release);
|
||||
bool release,
|
||||
bool forceSync);
|
||||
|
||||
static int InsertPrimary (TRI_index_t* idx, TRI_doc_mptr_t const* doc);
|
||||
static int UpdatePrimary (TRI_index_t* idx, TRI_doc_mptr_t const* doc, TRI_shaped_json_t const* old);
|
||||
|
@ -183,7 +186,8 @@ static TRI_datafile_t* SelectJournal (TRI_document_collection_t* sim,
|
|||
|
||||
static void WaitSync (TRI_document_collection_t* sim,
|
||||
TRI_datafile_t* journal,
|
||||
char const* position) {
|
||||
char const* position,
|
||||
bool forceSync) {
|
||||
TRI_collection_t* base;
|
||||
|
||||
base = &sim->base.base;
|
||||
|
@ -191,7 +195,7 @@ static void WaitSync (TRI_document_collection_t* sim,
|
|||
// no condition at all. Do NOT acquire a lock, in the worst
|
||||
// case we will miss a parameter change.
|
||||
|
||||
if (! base->_waitForSync) {
|
||||
if (! base->_waitForSync && ! forceSync) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -216,7 +220,10 @@ static void WaitSync (TRI_document_collection_t* sim,
|
|||
}
|
||||
|
||||
// we have to wait a bit longer
|
||||
// signal the synchroniser that there is work to do
|
||||
TRI_INC_SYNCHRONISER_WAITER_VOC_BASE(sim->base.base._vocbase);
|
||||
TRI_WAIT_JOURNAL_ENTRIES_DOC_COLLECTION(sim);
|
||||
TRI_DEC_SYNCHRONISER_WAITER_VOC_BASE(sim->base.base._vocbase);
|
||||
}
|
||||
|
||||
TRI_UNLOCK_JOURNAL_ENTRIES_DOC_COLLECTION(sim);
|
||||
|
@ -308,7 +315,8 @@ static TRI_doc_mptr_t CreateDocument (TRI_document_collection_t* sim,
|
|||
void const* additional,
|
||||
TRI_voc_did_t did,
|
||||
TRI_voc_rid_t rid,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
|
||||
TRI_datafile_t* journal;
|
||||
TRI_primary_collection_t* primary;
|
||||
|
@ -393,7 +401,7 @@ static TRI_doc_mptr_t CreateDocument (TRI_document_collection_t* sim,
|
|||
LOG_DEBUG("encountered index violation during create, deleting newly created document");
|
||||
|
||||
// rollback, ignore any additional errors
|
||||
resRollback = DeleteShapedJson(primary, header->_did, header->_rid, 0, TRI_DOC_UPDATE_LAST_WRITE, false);
|
||||
resRollback = DeleteShapedJson(primary, header->_did, header->_rid, 0, TRI_DOC_UPDATE_LAST_WRITE, false, false);
|
||||
|
||||
if (resRollback != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("encountered error '%s' during rollback of create", TRI_last_error());
|
||||
|
@ -426,7 +434,7 @@ static TRI_doc_mptr_t CreateDocument (TRI_document_collection_t* sim,
|
|||
LOG_DEBUG("removing document '%lu' because of cap constraint",
|
||||
(unsigned long) oldest->_did);
|
||||
|
||||
remRes = DeleteShapedJson(primary, oldest->_did, 0, NULL, TRI_DOC_UPDATE_LAST_WRITE, false);
|
||||
remRes = DeleteShapedJson(primary, oldest->_did, 0, NULL, TRI_DOC_UPDATE_LAST_WRITE, false, false);
|
||||
|
||||
if (remRes != TRI_ERROR_NO_ERROR) {
|
||||
LOG_WARNING("cannot cap collection: %s", TRI_last_error());
|
||||
|
@ -441,7 +449,7 @@ static TRI_doc_mptr_t CreateDocument (TRI_document_collection_t* sim,
|
|||
}
|
||||
|
||||
// wait for sync
|
||||
WaitSync(sim, journal, ((char const*) *result) + markerSize + bodySize);
|
||||
WaitSync(sim, journal, ((char const*) *result) + markerSize + bodySize, forceSync);
|
||||
|
||||
// and return
|
||||
return mptr;
|
||||
|
@ -529,13 +537,16 @@ static TRI_doc_mptr_t RollbackUpdate (TRI_document_collection_t* sim,
|
|||
|
||||
return UpdateDocument(sim,
|
||||
header,
|
||||
marker, markerLength,
|
||||
data, dataLength,
|
||||
marker,
|
||||
markerLength,
|
||||
data,
|
||||
dataLength,
|
||||
header->_rid,
|
||||
NULL,
|
||||
TRI_DOC_UPDATE_LAST_WRITE,
|
||||
result,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
|
@ -554,7 +565,8 @@ static TRI_doc_mptr_t UpdateDocument (TRI_document_collection_t* collection,
|
|||
TRI_doc_update_policy_e policy,
|
||||
TRI_df_marker_t** result,
|
||||
bool release,
|
||||
bool allowRollback) {
|
||||
bool allowRollback,
|
||||
bool forceSync) {
|
||||
TRI_doc_mptr_t mptr;
|
||||
TRI_primary_collection_t* primary;
|
||||
TRI_datafile_t* journal;
|
||||
|
@ -704,7 +716,7 @@ static TRI_doc_mptr_t UpdateDocument (TRI_document_collection_t* collection,
|
|||
}
|
||||
|
||||
// wait for sync
|
||||
WaitSync(collection, journal, ((char const*) *result) + markerSize + bodySize);
|
||||
WaitSync(collection, journal, ((char const*) *result) + markerSize + bodySize, forceSync);
|
||||
|
||||
// and return
|
||||
return mptr;
|
||||
|
@ -739,7 +751,8 @@ static int DeleteDocument (TRI_document_collection_t* collection,
|
|||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
TRI_datafile_t* journal;
|
||||
TRI_df_marker_t* result;
|
||||
TRI_doc_mptr_t const* header;
|
||||
|
@ -850,7 +863,7 @@ static int DeleteDocument (TRI_document_collection_t* collection,
|
|||
}
|
||||
|
||||
// wait for sync
|
||||
WaitSync(collection, journal, ((char const*) result) + sizeof(TRI_doc_deletion_marker_t));
|
||||
WaitSync(collection, journal, ((char const*) result) + sizeof(TRI_doc_deletion_marker_t), forceSync);
|
||||
}
|
||||
else {
|
||||
if (release) {
|
||||
|
@ -978,7 +991,8 @@ static TRI_doc_mptr_t CreateShapedJson (TRI_primary_collection_t* primary,
|
|||
void const* data,
|
||||
TRI_voc_did_t did,
|
||||
TRI_voc_rid_t rid,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
TRI_df_marker_t* result;
|
||||
TRI_document_collection_t* collection;
|
||||
|
||||
|
@ -1002,7 +1016,8 @@ static TRI_doc_mptr_t CreateShapedJson (TRI_primary_collection_t* primary,
|
|||
data,
|
||||
did,
|
||||
rid,
|
||||
release);
|
||||
release,
|
||||
forceSync);
|
||||
}
|
||||
else if (type == TRI_DOC_MARKER_EDGE) {
|
||||
TRI_doc_edge_marker_t marker;
|
||||
|
@ -1025,12 +1040,14 @@ static TRI_doc_mptr_t CreateShapedJson (TRI_primary_collection_t* primary,
|
|||
|
||||
return CreateDocument(collection,
|
||||
&marker.base, sizeof(marker),
|
||||
json->_data.data, json->_data.length,
|
||||
json->_data.data,
|
||||
json->_data.length,
|
||||
&result,
|
||||
data,
|
||||
did,
|
||||
rid,
|
||||
release);
|
||||
release,
|
||||
forceSync);
|
||||
}
|
||||
else {
|
||||
LOG_FATAL("unknown marker type %lu", (unsigned long) type);
|
||||
|
@ -1069,7 +1086,8 @@ static TRI_doc_mptr_t UpdateShapedJson (TRI_primary_collection_t* primary,
|
|||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
TRI_df_marker_t const* original;
|
||||
TRI_df_marker_t* result;
|
||||
TRI_document_collection_t* collection;
|
||||
|
@ -1116,7 +1134,8 @@ static TRI_doc_mptr_t UpdateShapedJson (TRI_primary_collection_t* primary,
|
|||
policy,
|
||||
&result,
|
||||
release,
|
||||
true);
|
||||
true,
|
||||
forceSync);
|
||||
}
|
||||
|
||||
// the original is an edge
|
||||
|
@ -1143,14 +1162,17 @@ static TRI_doc_mptr_t UpdateShapedJson (TRI_primary_collection_t* primary,
|
|||
|
||||
return UpdateDocument(collection,
|
||||
header,
|
||||
&marker.base, sizeof(marker),
|
||||
json->_data.data, json->_data.length,
|
||||
&marker.base,
|
||||
sizeof(marker),
|
||||
json->_data.data,
|
||||
json->_data.length,
|
||||
rid,
|
||||
oldRid,
|
||||
policy,
|
||||
&result,
|
||||
release,
|
||||
true);
|
||||
true,
|
||||
forceSync);
|
||||
}
|
||||
|
||||
// do not know
|
||||
|
@ -1174,7 +1196,8 @@ static int DeleteShapedJson (TRI_primary_collection_t* primary,
|
|||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
TRI_document_collection_t* document;
|
||||
TRI_doc_deletion_marker_t marker;
|
||||
|
||||
|
@ -1188,7 +1211,7 @@ static int DeleteShapedJson (TRI_primary_collection_t* primary,
|
|||
marker._did = did;
|
||||
marker._sid = 0;
|
||||
|
||||
return DeleteDocument(document, &marker, rid, oldRid, policy, release);
|
||||
return DeleteDocument(document, &marker, rid, oldRid, policy, release, forceSync);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -82,9 +82,10 @@ static bool IsEqualKeyDocument (TRI_associative_pointer_t* array, void const* ke
|
|||
static TRI_voc_did_t CreateLock (TRI_primary_collection_t* document,
|
||||
TRI_df_marker_type_e type,
|
||||
TRI_shaped_json_t const* json,
|
||||
void const* data) {
|
||||
void const* data,
|
||||
bool forceSync) {
|
||||
document->beginWrite(document);
|
||||
return document->create(document, type, json, data, 0, 0, true)._did;
|
||||
return document->create(document, type, json, data, 0, 0, true, forceSync)._did;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -96,7 +97,8 @@ static TRI_doc_mptr_t CreateJson (TRI_primary_collection_t* collection,
|
|||
TRI_json_t const* json,
|
||||
void const* data,
|
||||
bool reuseId,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
TRI_shaped_json_t* shaped;
|
||||
TRI_doc_mptr_t result;
|
||||
TRI_voc_did_t did = 0;
|
||||
|
@ -122,7 +124,7 @@ static TRI_doc_mptr_t CreateJson (TRI_primary_collection_t* collection,
|
|||
}
|
||||
}
|
||||
|
||||
result = collection->create(collection, type, shaped, data, did, rid, release);
|
||||
result = collection->create(collection, type, shaped, data, did, rid, release, forceSync);
|
||||
|
||||
TRI_FreeShapedJson(collection->_shaper, shaped);
|
||||
|
||||
|
@ -138,11 +140,12 @@ static int UpdateLock (TRI_primary_collection_t* document,
|
|||
TRI_voc_did_t did,
|
||||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy) {
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool forceSync) {
|
||||
TRI_doc_mptr_t result;
|
||||
|
||||
document->beginWrite(document);
|
||||
result = document->update(document, json, did, rid, oldRid, policy, true);
|
||||
result = document->update(document, json, did, rid, oldRid, policy, true, forceSync);
|
||||
|
||||
if (result._did == 0) {
|
||||
return TRI_errno();
|
||||
|
@ -162,7 +165,8 @@ static TRI_doc_mptr_t UpdateJson (TRI_primary_collection_t* collection,
|
|||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool release) {
|
||||
bool release,
|
||||
bool forceSync) {
|
||||
TRI_shaped_json_t* shaped;
|
||||
TRI_doc_mptr_t result;
|
||||
|
||||
|
@ -174,7 +178,7 @@ static TRI_doc_mptr_t UpdateJson (TRI_primary_collection_t* collection,
|
|||
return result;
|
||||
}
|
||||
|
||||
result = collection->update(collection, shaped, did, rid, oldRid, policy, release);
|
||||
result = collection->update(collection, shaped, did, rid, oldRid, policy, release, forceSync);
|
||||
|
||||
TRI_FreeShapedJson(collection->_shaper, shaped);
|
||||
|
||||
|
@ -189,9 +193,10 @@ static int DestroyLock (TRI_primary_collection_t* document,
|
|||
TRI_voc_did_t did,
|
||||
TRI_voc_rid_t rid,
|
||||
TRI_voc_rid_t* oldRid,
|
||||
TRI_doc_update_policy_e policy) {
|
||||
TRI_doc_update_policy_e policy,
|
||||
bool forceSync) {
|
||||
document->beginWrite(document);
|
||||
return document->destroy(document, did, rid, oldRid, policy, true);
|
||||
return document->destroy(document, did, rid, oldRid, policy, true, forceSync);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -329,18 +329,18 @@ typedef struct TRI_primary_collection_s {
|
|||
void (*createHeader) (struct TRI_primary_collection_s*, TRI_datafile_t*, TRI_df_marker_t const*, size_t, TRI_doc_mptr_t*, void const* data);
|
||||
void (*updateHeader) (struct TRI_primary_collection_s*, TRI_datafile_t*, TRI_df_marker_t const*, size_t, TRI_doc_mptr_t const*, TRI_doc_mptr_t*);
|
||||
|
||||
TRI_doc_mptr_t (*create) (struct TRI_primary_collection_s*, TRI_df_marker_type_e, TRI_shaped_json_t const*, void const*, TRI_voc_did_t, TRI_voc_rid_t, bool);
|
||||
TRI_doc_mptr_t (*createJson) (struct TRI_primary_collection_s*, TRI_df_marker_type_e, TRI_json_t const*, void const*, bool, bool);
|
||||
TRI_voc_did_t (*createLock) (struct TRI_primary_collection_s*, TRI_df_marker_type_e, TRI_shaped_json_t const*, void const*);
|
||||
TRI_doc_mptr_t (*create) (struct TRI_primary_collection_s*, TRI_df_marker_type_e, TRI_shaped_json_t const*, void const*, TRI_voc_did_t, TRI_voc_rid_t, bool, bool);
|
||||
TRI_doc_mptr_t (*createJson) (struct TRI_primary_collection_s*, TRI_df_marker_type_e, TRI_json_t const*, void const*, bool, bool, bool);
|
||||
TRI_voc_did_t (*createLock) (struct TRI_primary_collection_s*, TRI_df_marker_type_e, TRI_shaped_json_t const*, void const*, bool);
|
||||
|
||||
TRI_doc_mptr_t (*read) (struct TRI_primary_collection_s*, TRI_voc_did_t);
|
||||
|
||||
TRI_doc_mptr_t (*update) (struct TRI_primary_collection_s*, TRI_shaped_json_t const*, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool);
|
||||
TRI_doc_mptr_t (*updateJson) (struct TRI_primary_collection_s*, TRI_json_t const*, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool);
|
||||
int (*updateLock) (struct TRI_primary_collection_s*, TRI_shaped_json_t const*, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e);
|
||||
TRI_doc_mptr_t (*update) (struct TRI_primary_collection_s*, TRI_shaped_json_t const*, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool, bool);
|
||||
TRI_doc_mptr_t (*updateJson) (struct TRI_primary_collection_s*, TRI_json_t const*, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool, bool);
|
||||
int (*updateLock) (struct TRI_primary_collection_s*, TRI_shaped_json_t const*, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool);
|
||||
|
||||
int (*destroy) (struct TRI_primary_collection_s* collection, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool);
|
||||
int (*destroyLock) (struct TRI_primary_collection_s* collection, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e);
|
||||
int (*destroy) (struct TRI_primary_collection_s* collection, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool, bool);
|
||||
int (*destroyLock) (struct TRI_primary_collection_s* collection, TRI_voc_did_t, TRI_voc_rid_t, TRI_voc_rid_t*, TRI_doc_update_policy_e, bool);
|
||||
|
||||
TRI_doc_collection_info_t* (*figures) (struct TRI_primary_collection_s* collection);
|
||||
TRI_voc_size_t (*size) (struct TRI_primary_collection_s* collection);
|
||||
|
|
Loading…
Reference in New Issue