Skip to content

Commit 1214a6f

Browse files
authored
Merge pull request #149 from apkar/more-logs
More logs
2 parents 44be7b2 + a8db784 commit 1214a6f

File tree

5 files changed

+20
-28
lines changed

5 files changed

+20
-28
lines changed

src/DocLayer.actor.cpp

Lines changed: 6 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,9 @@ int main(int argc, char** argv) {
954955
}
955956
#endif
956957
if (metricPluginPath && metricPluginPath[0]) {
958+
TraceEvent(SevInfo, "MetricsInit")
959+
.detail("pluginPath", metricPluginPath)
960+
.detail("config", metricReporterConfig);
957961
DocumentLayer::metricReporter = IMetricReporter::init(metricPluginPath, metricReporterConfig.c_str());
958962
} else {
959963
// default to use `ConsoleMetric` plugin

src/ExtMsg.actor.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,17 +331,15 @@ ACTOR static Future<int32_t> addDocumentsFromCursor(Reference<Cursor> cursor,
331331

332332
while (!numberToReturn || remaining) {
333333
try {
334-
335334
if ((returned <= DOCLAYER_KNOBS->MAX_RETURNABLE_DOCUMENTS ||
336335
returnedSize <= DOCLAYER_KNOBS->DEFAULT_RETURNABLE_DATA_SIZE) &&
337336
returnedSize <= DOCLAYER_KNOBS->MAX_RETURNABLE_DATA_SIZE) {
337+
338338
Reference<ScanReturnedContext> doc = waitNext(cursor->docs);
339-
bson::BSONObj obj =
340-
doc->toDataValue()
341-
.get()
342-
.getPackedObject()
343-
.getOwned(); // Note that this call to get() is safe here but not in general, because we know
344-
// that doc is wrapping a BsonContext, which means toDataValue() is synchronous.
339+
340+
// Note that this call to get() is safe here but not in general, because we know
341+
// that doc is wrapping a BsonContext, which means toDataValue() is synchronous.
342+
bson::BSONObj obj = doc->toDataValue().get().getPackedObject().getOwned();
345343
cursor->checkpoint->getDocumentFinishedLock()->release();
346344
reply->addDocument(obj);
347345

@@ -361,7 +359,7 @@ ACTOR static Future<int32_t> addDocumentsFromCursor(Reference<Cursor> cursor,
361359
stop = false;
362360
break;
363361
}
364-
TraceEvent(SevError, "BD_runQuery2").detail("error", e.what());
362+
TraceEvent(SevError, "BD_runQuery2").error(e);
365363
throw;
366364
}
367365
}
@@ -469,7 +467,7 @@ ACTOR static Future<Void> runQuery(Reference<ExtConnection> ec,
469467
}
470468

471469
// If EXHAUST not set OR it is but we got <=0 results, stop.
472-
if (!(msg->flags & EXHAUST) || returned <= 0)
470+
if (!exhaust || returned <= 0)
473471
break;
474472

475473
++replies;

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)