mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into engine-vs-velocystream
This commit is contained in:
commit
999e2dab1b
|
@ -406,13 +406,15 @@ int Syncer::applyCollectionDumpMarker(
|
||||||
res = opRes.code;
|
res = opRes.code;
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
res = ex.code();
|
res = ex.code();
|
||||||
} catch (...) {
|
|
||||||
res = TRI_ERROR_INTERNAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
errorMsg = "document insert/replace operation failed: " +
|
errorMsg = "document insert/replace operation failed: " +
|
||||||
std::string(TRI_errno_string(res));
|
std::string(TRI_errno_string(res));
|
||||||
|
} catch (std::exception const& ex) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
errorMsg = "document insert/replace operation failed: " +
|
||||||
|
std::string(ex.what());
|
||||||
|
} catch (...) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
errorMsg = "document insert/replace operation failed: unknown exception";
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -436,13 +438,14 @@ int Syncer::applyCollectionDumpMarker(
|
||||||
res = opRes.code;
|
res = opRes.code;
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
res = ex.code();
|
res = ex.code();
|
||||||
} catch (...) {
|
|
||||||
res = TRI_ERROR_INTERNAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
errorMsg = "document remove operation failed: " +
|
errorMsg = "document remove operation failed: " +
|
||||||
std::string(TRI_errno_string(res));
|
std::string(TRI_errno_string(res));
|
||||||
|
} catch (std::exception const& ex) {
|
||||||
|
errorMsg = "document remove operation failed: " +
|
||||||
|
std::string(ex.what());
|
||||||
|
} catch (...) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
errorMsg = "document remove operation failed: unknown exception";
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -611,17 +611,24 @@ static int WriteBeginMarker(TRI_transaction_t* trx) {
|
||||||
arangodb::wal::TransactionMarker marker(TRI_DF_MARKER_VPACK_BEGIN_TRANSACTION, trx->_vocbase->id(), trx->_id);
|
arangodb::wal::TransactionMarker marker(TRI_DF_MARKER_VPACK_BEGIN_TRANSACTION, trx->_vocbase->id(), trx->_id);
|
||||||
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
|
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
|
||||||
|
|
||||||
|
TRI_IF_FAILURE("TransactionWriteBeginMarkerThrow") {
|
||||||
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
trx->_beginWritten = true;
|
trx->_beginWritten = true;
|
||||||
|
} else {
|
||||||
|
THROW_ARANGO_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
res = ex.code();
|
res = ex.code();
|
||||||
|
LOG(WARN) << "could not save transaction begin marker in log: " << ex.what();
|
||||||
|
} catch (std::exception const& ex) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
LOG(WARN) << "could not save transaction begin marker in log: " << ex.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
res = TRI_ERROR_INTERNAL;
|
res = TRI_ERROR_INTERNAL;
|
||||||
}
|
LOG(WARN) << "could not save transaction begin marker in log: unknown exception";
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
LOG(WARN) << "could not save transaction begin marker in log: " << TRI_errno_string(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -649,14 +656,23 @@ static int WriteAbortMarker(TRI_transaction_t* trx) {
|
||||||
try {
|
try {
|
||||||
arangodb::wal::TransactionMarker marker(TRI_DF_MARKER_VPACK_ABORT_TRANSACTION, trx->_vocbase->id(), trx->_id);
|
arangodb::wal::TransactionMarker marker(TRI_DF_MARKER_VPACK_ABORT_TRANSACTION, trx->_vocbase->id(), trx->_id);
|
||||||
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
|
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
|
||||||
|
|
||||||
|
TRI_IF_FAILURE("TransactionWriteAbortMarkerThrow") {
|
||||||
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
|
THROW_ARANGO_EXCEPTION(res);
|
||||||
|
}
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
res = ex.code();
|
res = ex.code();
|
||||||
|
LOG(WARN) << "could not save transaction abort marker in log: " << ex.what();
|
||||||
|
} catch (std::exception const& ex) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
LOG(WARN) << "could not save transaction abort marker in log: " << ex.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
res = TRI_ERROR_INTERNAL;
|
res = TRI_ERROR_INTERNAL;
|
||||||
}
|
LOG(WARN) << "could not save transaction abort marker in log: unknown exception";
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
LOG(WARN) << "could not save transaction abort marker in log: " << TRI_errno_string(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -692,15 +708,24 @@ static int WriteCommitMarker(TRI_transaction_t* trx) {
|
||||||
// also sync RocksDB WAL
|
// also sync RocksDB WAL
|
||||||
RocksDBFeature::syncWal();
|
RocksDBFeature::syncWal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") {
|
||||||
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
|
THROW_ARANGO_EXCEPTION(res);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
res = ex.code();
|
res = ex.code();
|
||||||
|
LOG(WARN) << "could not save transaction commit marker in log: " << ex.what();
|
||||||
|
} catch (std::exception const& ex) {
|
||||||
|
res = TRI_ERROR_INTERNAL;
|
||||||
|
LOG(WARN) << "could not save transaction commit marker in log: " << ex.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
res = TRI_ERROR_INTERNAL;
|
res = TRI_ERROR_INTERNAL;
|
||||||
}
|
LOG(WARN) << "could not save transaction commit marker in log: unknown exception";
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
LOG(WARN) << "could not save transaction commit marker in log: " << TRI_errno_string(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -5017,6 +5017,135 @@ function transactionServerFailuresSuite () {
|
||||||
|
|
||||||
testHelper.waitUnload(c);
|
testHelper.waitUnload(c);
|
||||||
|
|
||||||
|
assertEqual(100, c.count());
|
||||||
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test: cannot write begin marker for trx
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testNoBeginMarkerThrow : function () {
|
||||||
|
internal.debugClearFailAt();
|
||||||
|
|
||||||
|
db._drop(cn);
|
||||||
|
c = db._create(cn);
|
||||||
|
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < 100; ++i) {
|
||||||
|
c.save({ _key: "test" + i, a: i });
|
||||||
|
}
|
||||||
|
assertEqual(100, c.count());
|
||||||
|
|
||||||
|
internal.wal.flush(true, true);
|
||||||
|
internal.debugSetFailAt("TransactionWriteBeginMarkerThrow");
|
||||||
|
|
||||||
|
try {
|
||||||
|
TRANSACTION({
|
||||||
|
collections: {
|
||||||
|
write: [ cn ],
|
||||||
|
},
|
||||||
|
action: function () {
|
||||||
|
c.save({ _key: "test100" });
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
assertEqual(internal.errors.ERROR_INTERNAL.code, err.errorNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEqual(100, c.count());
|
||||||
|
internal.debugClearFailAt();
|
||||||
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test: cannot write commit marker for trx
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testNoCommitMarkerThrow : function () {
|
||||||
|
internal.debugClearFailAt();
|
||||||
|
|
||||||
|
db._drop(cn);
|
||||||
|
c = db._create(cn);
|
||||||
|
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < 100; ++i) {
|
||||||
|
c.save({ _key: "test" + i, a: i });
|
||||||
|
}
|
||||||
|
assertEqual(100, c.count());
|
||||||
|
|
||||||
|
internal.wal.flush(true, true);
|
||||||
|
internal.debugSetFailAt("TransactionWriteCommitMarkerThrow");
|
||||||
|
|
||||||
|
try {
|
||||||
|
TRANSACTION({
|
||||||
|
collections: {
|
||||||
|
write: [ cn ],
|
||||||
|
},
|
||||||
|
action: function () {
|
||||||
|
var i;
|
||||||
|
for (i = 100; i < 1000; ++i) {
|
||||||
|
c.save({ _key: "test" + i, a: i });
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEqual(1000, c.count());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
assertEqual(internal.errors.ERROR_INTERNAL.code, err.errorNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEqual(100, c.count());
|
||||||
|
internal.debugClearFailAt();
|
||||||
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test: cannot write abort marker for trx
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testNoAbortMarkerThrow : function () {
|
||||||
|
internal.debugClearFailAt();
|
||||||
|
|
||||||
|
db._drop(cn);
|
||||||
|
c = db._create(cn);
|
||||||
|
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < 100; ++i) {
|
||||||
|
c.save({ _key: "test" + i, a: i });
|
||||||
|
}
|
||||||
|
assertEqual(100, c.count());
|
||||||
|
|
||||||
|
internal.wal.flush(true, true);
|
||||||
|
internal.debugSetFailAt("TransactionWriteAbortMarkerThrow");
|
||||||
|
|
||||||
|
try {
|
||||||
|
TRANSACTION({
|
||||||
|
collections: {
|
||||||
|
write: [ cn ],
|
||||||
|
},
|
||||||
|
action: function () {
|
||||||
|
var i;
|
||||||
|
for (i = 100; i < 1000; ++i) {
|
||||||
|
c.save({ _key: "test" + i, a: i });
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEqual(1000, c.count());
|
||||||
|
|
||||||
|
throw "rollback!";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
// ignore the intentional error
|
||||||
|
}
|
||||||
|
|
||||||
|
internal.debugClearFailAt();
|
||||||
|
|
||||||
|
testHelper.waitUnload(c);
|
||||||
|
|
||||||
assertEqual(100, c.count());
|
assertEqual(100, c.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue