1
0
Fork 0

cleanup a few cases of fatal errors (#3274)

* cleanup a few cases of fatal errors

* fix multiple compile errors (my bad)

* fixed missing brace
This commit is contained in:
Jan 2017-09-19 21:58:21 +02:00 committed by Frank Celler
parent 4a648a68c1
commit dba4b90754
7 changed files with 28 additions and 26 deletions

View File

@ -65,7 +65,7 @@ namespace {
static int indexOf(std::vector<std::string> const& haystack, std::string const& needle) {
for (size_t i = 0; i < haystack.size(); ++i) {
if (haystack[i] == needle) {
return i;
return static_cast<int>(i);
}
}
return -1;

View File

@ -98,7 +98,7 @@ void AuthenticationFeature::collectOptions(
void AuthenticationFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
if (!_jwtSecretProgramOption.empty()) {
if (_jwtSecretProgramOption.length() > _maxSecretLength) {
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
LOG_TOPIC(FATAL, arangodb::Logger::FIXME)
<< "Given JWT secret too long. Max length is " << _maxSecretLength;
FATAL_ERROR_EXIT();
}

View File

@ -287,7 +287,8 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
}
} else {
// unknown type
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "unknown ditch type '" << type << "'"; FATAL_ERROR_EXIT();
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "unknown ditch type '" << type << "'";
FATAL_ERROR_EXIT();
}
// next iteration

View File

@ -404,9 +404,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
int res = copyMarker(context->_compactor, marker, &result);
if (res != TRI_ERROR_NO_ERROR) {
// TODO: dont fail but recover from this state
LOG_TOPIC(FATAL, Logger::COMPACTOR) << "cannot write compactor file: " << TRI_errno_string(res);
FATAL_ERROR_EXIT();
THROW_ARANGO_EXCEPTION_MESSAGE(res, std::string("cannot write document marker into compactor file: ") + TRI_errno_string(res));
}
// let marker point to the new position
@ -425,9 +423,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
int res = copyMarker(context->_compactor, marker, &result);
if (res != TRI_ERROR_NO_ERROR) {
// TODO: dont fail but recover from this state
LOG_TOPIC(FATAL, Logger::COMPACTOR) << "cannot write document marker to compactor file: " << TRI_errno_string(res);
FATAL_ERROR_EXIT();
THROW_ARANGO_EXCEPTION_MESSAGE(res, std::string("cannot write remove marker into compactor file: ") + TRI_errno_string(res));
}
// update datafile info
@ -485,7 +481,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
}
// now compact all datafiles
uint64_t noCombined = 0;
uint64_t nrCombined = 0;
uint64_t compactionBytesRead = 0;
for (size_t i = 0; i < n; ++i) {
auto compaction = toCompact[i];
@ -495,27 +491,32 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
LOG_TOPIC(DEBUG, Logger::COMPACTOR) << "compacting datafile '" << df->getName() << "' into '" << compactor->getName() << "', number: " << i << ", keep deletions: " << compaction._keepDeletions;
// if this is the first datafile in the list of datafiles, we can also
// collect
// deletion markers
// collect deletion markers
context->_keepDeletions = compaction._keepDeletions;
// run the actual compaction of a single datafile
bool ok = TRI_IterateDatafile(df, compactifier);
bool ok;
try {
ok = TRI_IterateDatafile(df, compactifier);
} catch (std::exception const& ex) {
LOG_TOPIC(WARN, Logger::COMPACTOR) << "failed to compact datafile '" << df->getName() << "': " << ex.what();
throw;
}
if (!ok) {
LOG_TOPIC(WARN, Logger::COMPACTOR) << "failed to compact datafile '" << df->getName() << "'";
// compactor file does not need to be removed now. will be removed on next
// startup
// TODO: Remove file
return;
}
noCombined ++;
++nrCombined;
} // next file
TRI_ASSERT(context->_dfi.numberDead == 0);
TRI_ASSERT(context->_dfi.sizeDead == 0);
physical->_datafileStatistics.compactionRun(noCombined, compactionBytesRead, context->_dfi.sizeAlive);
physical->_datafileStatistics.compactionRun(nrCombined, compactionBytesRead, context->_dfi.sizeAlive);
physical->_datafileStatistics.replace(compactor->fid(), context->_dfi);
trx.commit();

View File

@ -87,7 +87,7 @@ int ScriptFeature::runScript(std::vector<std::string> const& scripts) {
localContext->Enter();
{
v8::Context::Scope contextScope(localContext);
for (auto script : scripts) {
for (auto const& script : scripts) {
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "executing script '" << script << "'";
bool r = TRI_ExecuteGlobalJavaScriptFile(isolate, script.c_str(), true);

View File

@ -225,7 +225,7 @@ class RandomDeviceDirect : public RandomDevice {
char* ptr = reinterpret_cast<char*>(&buffer);
while (0 < n) {
ssize_t r = TRI_READ(fd, ptr, (TRI_read_t)n);
ssize_t r = TRI_READ(fd, ptr, static_cast<TRI_read_t>(n));
if (r == 0) {
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "read on random device failed: nothing read";
@ -308,16 +308,17 @@ class RandomDeviceCombined : public RandomDevice {
char* ptr = reinterpret_cast<char*>(&buffer);
while (0 < n) {
ssize_t r = TRI_READ(fd, ptr, (TRI_read_t)n);
ssize_t r = TRI_READ(fd, ptr, static_cast<TRI_read_t>(n));
if (r == 0) {
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "read on random device failed: nothing read";
FATAL_ERROR_EXIT();
} else if (errno == EWOULDBLOCK || errno == EAGAIN) {
LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "not enough entropy (got " << (sizeof(buffer) - n)
<< "), switching to pseudo-random";
break;
} else if (r < 0) {
} else if (r < 0) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "not enough entropy (got " << (sizeof(buffer) - n)
<< "), switching to pseudo-random";
break;
}
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "read on random device failed: " << strerror(errno);
FATAL_ERROR_EXIT();
}

View File

@ -77,8 +77,7 @@ boost::asio::ssl::context arangodb::sslContext(
if (sslctx.native_handle() == nullptr) {
// could not create SSL context - this is mostly due to the OpenSSL
// library not having been initialized
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "unable to create SSL context";
FATAL_ERROR_EXIT();
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unable to create SSL context");
}
// load our keys and certificates