8000 Improve logging on coordinator when doing `arangorestore`. · Mars2018/arangodb@1ce781c · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ce781c

Browse files
committed
Improve logging on coordinator when doing arangorestore.
1 parent abfe01e commit 1ce781c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

arangod/RestHandler/RestReplicationHandler.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,16 +1398,35 @@ Result RestReplicationHandler::processRestoreDataBatch(
13981398
options.ignoreRevs = true;
13991399
options.isRestore = true;
14001400
options.waitForSync = false;
1401+
double startTime = TRI_microtime();
14011402
OperationResult opRes =
14021403
trx.remove(collectionName, oldBuilder.slice(), options);
1404+
double duration = TRI_microtime() - startTime;
14031405
if (opRes.fail()) {
1406+
LOG_TOPIC(WARN, Logger::CLUSTER)
1407+
<< "Could not delete " << oldBuilder.slice().length()
1408+
<< " documents for restore: "
1409+
<< opRes.result.errorMessage();
14041410
return opRes.result;
14051411
}
1412+
if (duration > 30) {
1413+
LOG_TOPIC(INFO, Logger::PERFORMANCE) << << "Restored/deleted "
1414+
<< oldBuilder.slice().length() << " documents in time: " << duration
1415+
<< " seconds.";
1416+
}
14061417
} catch (arangodb::basics::Exception const& ex) {
1418+
LOG_TOPIC(WARN, Logger::CLUSTER)
1419+
<< "Could not delete documents for restore exception (1): "
1420+
<< ex.what();
14071421
return Result(ex.code(), ex.what());
14081422
} catch (std::exception const& ex) {
1423+
LOG_TOPIC(WARN, Logger::CLUSTER)
1424+
<< "Could not delete documents for restore exception (2): "
1425+
<< ex.what();
14091426
return Result(TRI_ERROR_INTERNAL, ex.what());
14101427
} catch (...) {
1428+
LOG_TOPIC(WARN, Logger::CLUSTER)
1429+
<< "Could not delete documents for restore exception (3).";
14111430
return Result(TRI_ERROR_INTERNAL);
14121431
}
14131432

@@ -1478,15 +1497,34 @@ Result RestReplicationHandler::processRestoreDataBatch(
14781497
options.ignoreRevs = true;
14791498
options.isRestore = true;
14801499
options.waitForSync = false;
1500+
double startTime = TRI_microtime();
14811501
opRes = trx.insert(collectionName, requestSlice, options);
1502+
double duration = TRI_microtime() - startTime;
14821503
if (opRes.fail()) {
1504+
LOG_TOPIC(WARN, Logger::CLUSTER)
1505+
<< "Could not insert " << requestSlice.length()
1506+
<< " documents for restore: "
1507+
<< opRes.result.errorMessage();
14831508
return opRes.result;
14841509
}
1510+
if (duration > 30) {
1511+
LOG_TOPIC(INFO, Logger::PERFORMANCE) << << "Restored/inserted "
1512+
<< requestSlice.length() << " documents in time: " << duration
1513+
<< " seconds.";
1514+
}
14851515
} catch (arangodb::basics::Exception const& ex) {
1516+
LOG_TOPIC(WARN, Logger::CLUSTER)
1517+
<< "Could not insert documents for restore exception (1): "
1518+
<< ex.what();
14861519
return Result(ex.code(), ex.what());
14871520
} catch (std::exception const& ex) {
1521+
LOG_TOPIC(WARN, Logger::CLUSTER)
1522+
<< "Could not insert documents for restore exception (2): "
1523+
<< ex.what();
14881524
return Result(TRI_ERROR_INTERNAL, ex.what());
14891525
} catch (...) {
1526+
LOG_TOPIC(WARN, Logger::CLUSTER)
1527+
<< "Could not insert documents for restore exception (3).";
14901528
return Result(TRI_ERROR_INTERNAL);
14911529
}
14921530

@@ -1527,15 +1565,34 @@ Result RestReplicationHandler::processRestoreDataBatch(
15271565
options.ignoreRevs = true;
15281566
options.isRestore = true;
15291567
options.waitForSync = false;
1568+
double startTime = TRI_microtime();
15301569
opRes = trx.replace(collectionName, replBuilder.slice(), options);
1570+
double duration = TRI_microtime() - startTime;
15311571
if (opRes.fail()) {
1572+
LOG_TOPIC(WARN, Logger::CLUSTER)
1573+
<< "Could not replace " << replBuilder.slice().length()
1574+
<< " documents for restore: "
1575+
<< opRes.result.errorMessage();
15321576
return opRes.result;
15331577
}
1578+
if (duration > 30) {
1579+
LOG_TOPIC(INFO, Logger::PERFORMANCE) << << "Restored/inserted "
1580+
<< replBuilder.slice().length() << " documents in time: " << duration
1581+
<< " seconds.";
1582+
}
15341583
} catch (arangodb::basics::Exception const& ex) {
1584+
LOG_TOPIC(WARN, Logger::CLUSTER)
1585+
<< "Could not replace documents for restore exception (1): "
1586+
<< ex.what();
15351587
return Result(ex.code(), ex.what());
15361588
} catch (std::exception const& ex) {
1589+
LOG_TOPIC(WARN, Logger::CLUSTER)
1590+
<< "Could not replace documents for restore exception (2): "
1591+
<< ex.what();
15371592
return Result(TRI_ERROR_INTERNAL, ex.what());
15381593
} catch (...) {
1594+
LOG_TOPIC(WARN, Logger::CLUSTER)
1595+
<< "Could not replace documents for restore exception (3).";
15391596
return Result(TRI_ERROR_INTERNAL);
15401597
}
15411598

0 commit comments

Comments
 (0)
0