mirror of https://gitee.com/bigwinds/arangodb
remove revision id from storage engine if write locker cannot be acquired
This commit is contained in:
parent
8d3f411cae
commit
9889e9f91f
|
@ -2064,55 +2064,56 @@ int LogicalCollection::insert(Transaction* trx, VPackSlice const slice,
|
||||||
|
|
||||||
try {
|
try {
|
||||||
insertRevision(revisionId, marker->vpack(), 0, true);
|
insertRevision(revisionId, marker->vpack(), 0, true);
|
||||||
|
// and go on with the insertion...
|
||||||
} catch (basics::Exception const& ex) {
|
} catch (basics::Exception const& ex) {
|
||||||
res = ex.code();
|
return ex.code();
|
||||||
} catch (std::bad_alloc const&) {
|
} catch (std::bad_alloc const&) {
|
||||||
res = TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
res = TRI_ERROR_INTERNAL;
|
return TRI_ERROR_INTERNAL;
|
||||||
}
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
try {
|
|
||||||
removeRevision(revisionId, false);
|
|
||||||
} catch (basics::Exception const& ex) {
|
|
||||||
res = ex.code();
|
|
||||||
} catch (std::bad_alloc const&) {
|
|
||||||
res = TRI_ERROR_OUT_OF_MEMORY;
|
|
||||||
} catch (...) {
|
|
||||||
res = TRI_ERROR_INTERNAL;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// use lock
|
// use lock?
|
||||||
bool const useDeadlockDetector =
|
bool const useDeadlockDetector =
|
||||||
(lock && !trx->isSingleOperationTransaction());
|
(lock && !trx->isSingleOperationTransaction());
|
||||||
arangodb::CollectionWriteLocker collectionLocker(this, useDeadlockDetector,
|
|
||||||
lock);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// insert into indexes
|
arangodb::CollectionWriteLocker collectionLocker(this, useDeadlockDetector,
|
||||||
res = insertDocument(trx, revisionId, doc, operation, marker,
|
lock);
|
||||||
options.waitForSync);
|
|
||||||
} catch (basics::Exception const& ex) {
|
try {
|
||||||
res = ex.code();
|
// insert into indexes
|
||||||
} catch (std::bad_alloc const&) {
|
res = insertDocument(trx, revisionId, doc, operation, marker,
|
||||||
res = TRI_ERROR_OUT_OF_MEMORY;
|
options.waitForSync);
|
||||||
|
} catch (basics::Exception const& ex) {
|
||||||
|
res = ex.code();
|
||||||
|
} catch (std::bad_alloc const&) {
|
||||||
|
res = TRI_ERROR_OUT_OF_MEMORY;
|
||||||
|
} catch (...) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
res = TRI_ERROR_INTERNAL;
|
// the collectionLocker may have thrown in its constructor...
|
||||||
|
// if it did, then we need to manually remove the revision id
|
||||||
|
// from the list of revisions
|
||||||
|
try {
|
||||||
|
removeRevision(revisionId, false);
|
||||||
|
} catch (...) {
|
||||||
|
}
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
operation.revert(trx);
|
operation.revert(trx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
readRevision(trx, result, revisionId);
|
readRevision(trx, result, revisionId);
|
||||||
|
|
||||||
// store the tick that was used for writing the document
|
// store the tick that was used for writing the document
|
||||||
resultMarkerTick = operation.tick();
|
resultMarkerTick = operation.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue