1
0
Fork 0

more diagnostic output

This commit is contained in:
Jan Steemann 2016-08-25 14:00:55 +02:00
parent 34a31f2b97
commit 3600ed40f8
2 changed files with 168 additions and 12 deletions

View File

@ -611,18 +611,25 @@ static int WriteBeginMarker(TRI_transaction_t* trx) {
try {
arangodb::wal::TransactionMarker marker(TRI_DF_MARKER_VPACK_BEGIN_TRANSACTION, trx->_vocbase->_id, trx->_id);
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
TRI_IF_FAILURE("TransactionWriteBeginMarkerThrow") {
throw std::bad_alloc();
}
if (res == TRI_ERROR_NO_ERROR) {
trx->_beginWritten = true;
} else {
THROW_ARANGO_EXCEPTION(res);
}
} catch (arangodb::basics::Exception const& ex) {
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 (...) {
res = TRI_ERROR_INTERNAL;
}
if (res != TRI_ERROR_NO_ERROR) {
LOG(WARN) << "could not save transaction begin marker in log: " << TRI_errno_string(res);
LOG(WARN) << "could not save transaction begin marker in log: unknown exception";
}
return res;
@ -650,14 +657,23 @@ static int WriteAbortMarker(TRI_transaction_t* trx) {
try {
arangodb::wal::TransactionMarker marker(TRI_DF_MARKER_VPACK_ABORT_TRANSACTION, trx->_vocbase->_id, trx->_id);
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) {
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 (...) {
res = TRI_ERROR_INTERNAL;
}
if (res != TRI_ERROR_NO_ERROR) {
LOG(WARN) << "could not save transaction abort marker in log: " << TRI_errno_string(res);
LOG(WARN) << "could not save transaction abort marker in log: unknown exception";
}
return res;
@ -693,15 +709,24 @@ static int WriteCommitMarker(TRI_transaction_t* trx) {
// also sync RocksDB WAL
RocksDBFeature::syncWal();
}
TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") {
throw std::bad_alloc();
}
if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION(res);
}
#endif
} catch (arangodb::basics::Exception const& ex) {
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 (...) {
res = TRI_ERROR_INTERNAL;
}
if (res != TRI_ERROR_NO_ERROR) {
LOG(WARN) << "could not save transaction commit marker in log: " << TRI_errno_string(res);
LOG(WARN) << "could not save transaction commit marker in log: unknown exception";
}
return res;

View File

@ -5011,6 +5011,137 @@ function transactionServerFailuresSuite () {
}
catch (err) {
// ignore the intentional error
assertEqual(internal.errors.ERROR_DEBUG.code, err.errorNum);
}
internal.debugClearFailAt();
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
assertEqual(internal.errors.ERROR_INTERNAL.code, err.errorNum);
}
internal.debugClearFailAt();