Skip to content

Commit 9d4cbab

Browse files
committed
Better error messages.
* TraceEvent().error(e) gives better error context * Removed some commented code.
1 parent 44be7b2 commit 9d4cbab

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

src/DocLayer.actor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Future<Void> processRequest(Reference<ExtConnection> ec,
155155
fprintf(stderr, "C -> S: %s\n\n", msg->toString().c_str());
156156
return msg->run(ec);
157157
} catch (Error& e) {
158-
TraceEvent(SevWarnAlways, "BD_processRequest").detail("errorUnknownOpCode", header->opCode);
158+
TraceEvent(SevWarnAlways, "BD_processRequest").detail("opcode", header->opCode).error(e);
159159
return Void();
160160
}
161161
}
@@ -473,7 +473,7 @@ ACTOR void setup(NetworkAddress na,
473473
state Reference<Transaction> tr3(new Transaction(db));
474474
Optional<FDB::FDBStandalone<StringRef>> clusterFilePath =
475475
wait(tr3->get(LiteralStringRef("\xff\xff/cluster_file_path")));
476-
TraceEvent("StartupConfig").detail("clusterfile", clusterFilePath.get().toString());
476+
TraceEvent("StartupConfig").detail("clusterFile", clusterFilePath.get().toString());
477477
} catch (Error& e) {
478478
if (e.code() != error_code_key_outside_legal_range) // KV-store 2.0
479479
throw;
@@ -505,6 +505,7 @@ ACTOR void setup(NetworkAddress na,
505505
try {
506506
Void _ = wait(tr2->onError(e));
507507
} catch (Error& e) {
508+
TraceEvent(SevError, "ConnectionFailure").error(e);
508509
fprintf(stderr, "Failed to connect to FDB connection! Error: %s\n", e.what());
509510
_exit(FDB_EXIT_ERROR);
510511
}
@@ -954,6 +955,7 @@ int main(int argc, char** argv) {
954955
}
955956
#endif
956957
if (metricPluginPath && metricPluginPath[0]) {
958+
TraceEvent(SevInfo, "MetricsInit").detail("pluginPath", metricPluginPath).detail("config", metricReporterConfig);
957959
DocumentLayer::metricReporter = IMetricReporter::init(metricPluginPath, metricReporterConfig.c_str());
958960
} else {
959961
// default to use `ConsoleMetric` plugin

src/ExtMsg.actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ ACTOR static Future<int32_t> addDocumentsFromCursor(Reference<Cursor> cursor,
361361
stop = false;
362362
break;
363363
}
364-
TraceEvent(SevError, "BD_runQuery2").detail("error", e.what());
364+
TraceEvent(SevError, "BD_runQuery2").error(e);
365365
throw;
366366
}
367367
}

src/QLContext.actor.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ ACTOR static Future<Void> FDBPlugin_getDescendants(DataKey key,
144144
state std::string end = std::move(prefix);
145145
end += relEnd;
146146

147-
// if (verboseLogging)
148-
// TraceEvent("BD_getDescendents").detail("from", printable(StringRef(begin)).c_str()).detail("to",
149-
// printable(StringRef(end)).c_str());
150-
151147
try {
152148
state GetRangeLimits limit(GetRangeLimits::ROW_LIMIT_UNLIMITED, 80000);
153149
state Future<FDBStandalone<RangeResultRef>> nextRead = tr->tr->getRange(KeyRangeRef(begin, end), limit);
@@ -178,7 +174,7 @@ ACTOR static Future<Void> FDBPlugin_getDescendants(DataKey key,
178174
throw end_of_stream();
179175
} catch (Error& e) {
180176
if (e.code() != error_code_end_of_stream && e.code() != error_code_operation_cancelled)
181-
TraceEvent(SevError, "BD_getDescendants").detail("error", e.what());
177+
TraceEvent(SevError, "BD_getDescendants").error(e);
182178
if (e.code() != error_code_operation_cancelled)
183179
output.sendError(e);
184180
throw;
@@ -325,8 +321,6 @@ struct CompoundIndexPlugin : IndexPlugin, ReferenceCounted<CompoundIndexPlugin>,
325321
state Future<Void> writes_finished = dd->writes_finished.getFuture();
326322

327323
try {
328-
// TraceEvent("BD_doIndexUpdateStart");
329-
330324
dd->snapshotLock.use();
331325

332326
std::vector<Future<std::vector<DataValue>>> f_old_values;
@@ -433,7 +427,7 @@ struct CompoundIndexPlugin : IndexPlugin, ReferenceCounted<CompoundIndexPlugin>,
433427
}
434428

435429
} catch (Error& e) {
436-
TraceEvent(SevError, "BD_doIndexUpdate").detail("error", e.what());
430+
TraceEvent(SevError, "BD_doIndexUpdate").error(e);
437431
throw;
438432
}
439433

@@ -475,8 +469,6 @@ struct SimpleIndexPlugin : IndexPlugin, ReferenceCounted<SimpleIndexPlugin>, Fas
475469
state Reference<QueryContext> doc(new QueryContext(self->next, tr, documentPath));
476470
state Future<Void> writes_finished = dd->writes_finished.getFuture();
477471
try {
478-
// TraceEvent("BD_doIndexUpdateStart");
479-
480472
dd->snapshotLock.use();
481473

482474
state std::vector<DataValue> old_values =
@@ -536,14 +528,12 @@ struct SimpleIndexPlugin : IndexPlugin, ReferenceCounted<SimpleIndexPlugin>, Fas
536528
}
537529
// clear any existing index entries
538530
for (DataValue& v : old_values) {
539-
// fprintf(stderr, "Old value: %s\n", printable(StringRef(v.encode_key_part())).c_str());
540531
DataKey old_key(self->indexPath);
541532
old_key.append(v.encode_key_part()).append(documentPath[documentPath.size() - 1]);
542533
tr->tr->clear(getFDBKey(old_key));
543534
}
544535
// write the new/updated index entries
545536
for (DataValue& v : new_values) {
546-
// fprintf(stderr, "New value: %s\n", printable(StringRef(v.encode_key_part())).c_str());
547537
DataKey new_key(self->indexPath);
548538
new_key.append(v.encode_key_part()).append(documentPath[documentPath.size() - 1]);
549539
if (new_key.byteSize() > DocLayerConstants::INDEX_KEY_LENGTH_LIMIT) {
@@ -555,7 +545,7 @@ struct SimpleIndexPlugin : IndexPlugin, ReferenceCounted<SimpleIndexPlugin>, Fas
555545
tr->tr->set(getFDBKey(new_key), StringRef());
556546
}
557547
} catch (Error& e) {
558-
TraceEvent(SevError, "BD_doIndexUpdate").detail("error", e.what());
548+
TraceEvent(SevError, "BD_doIndexUpdate").error(e);
559549
throw;
560550
}
561551

src/QLPlan.actor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ ACTOR static Future<Void> toDocInfo(PlanCheckpoint* checkpoint,
347347
throw;
348348
}
349349
if (e.code() != error_code_end_of_stream)
350-
TraceEvent(SevError, "BD_toDocInfo_error").detail("error", e.what());
350+
TraceEvent(SevError, "BD_toDocInfo_error").error(e);
351351
dis.sendError(e);
352352
throw;
353353
}
@@ -1516,7 +1516,7 @@ ACTOR static Future<Void> doSort(PlanCheckpoint* outerCheckpoint,
15161516
if (e.code() == error_code_end_of_stream) {
15171517
break;
15181518
}
1519-
TraceEvent(SevError, "BD_runQuery2").detail("error", e.what());
1519+
TraceEvent(SevError, "BD_runQuery2").error(e);
15201520
throw;
15211521
}
15221522
}
@@ -1535,7 +1535,7 @@ ACTOR static Future<Void> doSort(PlanCheckpoint* outerCheckpoint,
15351535
ref(new BsonContext(returnProjections[i].getObjectField("doc").getOwned(), false)), -1, Key())));
15361536
}
15371537
} catch (Error& e) {
1538-
TraceEvent(SevError, "BD_runQuery2").detail("error", e.what());
1538+
TraceEvent(SevError, "BD_runQuery2").error(e);
15391539
throw;
15401540
}
15411541
innerCheckpoint->stop();

src/QLProjection.actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ACTOR Future<bson::BSONObj> projectDocument_impl(Reference<IReadContext> doc, Re
105105
return currentPath[0].build().getOwned();
106106
} catch (Error& e) {
107107
if (e.code() != error_code_actor_cancelled)
108-
TraceEvent(SevError, "BD_projectDocument").detail("error", e.what());
108+
TraceEvent(SevError, "BD_projectDocument").error(e);
109109
throw;
110110
}
111111
}

0 commit comments

Comments
 (0)