diff --git a/src/DocLayer.actor.cpp b/src/DocLayer.actor.cpp index 03fba9f..a2d8dea 100644 --- a/src/DocLayer.actor.cpp +++ b/src/DocLayer.actor.cpp @@ -155,7 +155,7 @@ Future processRequest(Reference ec, fprintf(stderr, "C -> S: %s\n\n", msg->toString().c_str()); return msg->run(ec); } catch (Error& e) { - TraceEvent(SevWarnAlways, "BD_processRequest").detail("errorUnknownOpCode", header->opCode); + TraceEvent(SevWarnAlways, "BD_processRequest").detail("opcode", header->opCode).error(e); return Void(); } } @@ -473,7 +473,7 @@ ACTOR void setup(NetworkAddress na, state Reference tr3(new Transaction(db)); Optional> clusterFilePath = wait(tr3->get(LiteralStringRef("\xff\xff/cluster_file_path"))); - TraceEvent("StartupConfig").detail("clusterfile", clusterFilePath.get().toString()); + TraceEvent("StartupConfig").detail("clusterFile", clusterFilePath.get().toString()); } catch (Error& e) { if (e.code() != error_code_key_outside_legal_range) // KV-store 2.0 throw; @@ -505,6 +505,7 @@ ACTOR void setup(NetworkAddress na, try { Void _ = wait(tr2->onError(e)); } catch (Error& e) { + TraceEvent(SevError, "ConnectionFailure").error(e); fprintf(stderr, "Failed to connect to FDB connection! Error: %s\n", e.what()); _exit(FDB_EXIT_ERROR); } @@ -954,6 +955,9 @@ int main(int argc, char** argv) { } #endif if (metricPluginPath && metricPluginPath[0]) { + TraceEvent(SevInfo, "MetricsInit") + .detail("pluginPath", metricPluginPath) + .detail("config", metricReporterConfig); DocumentLayer::metricReporter = IMetricReporter::init(metricPluginPath, metricReporterConfig.c_str()); } else { // default to use `ConsoleMetric` plugin diff --git a/src/ExtMsg.actor.cpp b/src/ExtMsg.actor.cpp index ad6ba1b..31450ab 100644 --- a/src/ExtMsg.actor.cpp +++ b/src/ExtMsg.actor.cpp @@ -331,17 +331,15 @@ ACTOR static Future addDocumentsFromCursor(Reference cursor, while (!numberToReturn || remaining) { try { - if ((returned <= DOCLAYER_KNOBS->MAX_RETURNABLE_DOCUMENTS || returnedSize <= DOCLAYER_KNOBS->DEFAULT_RETURNABLE_DATA_SIZE) && returnedSize <= DOCLAYER_KNOBS->MAX_RETURNABLE_DATA_SIZE) { + Reference doc = waitNext(cursor->docs); - bson::BSONObj obj = - doc->toDataValue() - .get() - .getPackedObject() - .getOwned(); // Note that this call to get() is safe here but not in general, because we know - // that doc is wrapping a BsonContext, which means toDataValue() is synchronous. + + // Note that this call to get() is safe here but not in general, because we know + // that doc is wrapping a BsonContext, which means toDataValue() is synchronous. + bson::BSONObj obj = doc->toDataValue().get().getPackedObject().getOwned(); cursor->checkpoint->getDocumentFinishedLock()->release(); reply->addDocument(obj); @@ -361,7 +359,7 @@ ACTOR static Future addDocumentsFromCursor(Reference cursor, stop = false; break; } - TraceEvent(SevError, "BD_runQuery2").detail("error", e.what()); + TraceEvent(SevError, "BD_runQuery2").error(e); throw; } } @@ -469,7 +467,7 @@ ACTOR static Future runQuery(Reference ec, } // If EXHAUST not set OR it is but we got <=0 results, stop. - if (!(msg->flags & EXHAUST) || returned <= 0) + if (!exhaust || returned <= 0) break; ++replies; diff --git a/src/QLContext.actor.cpp b/src/QLContext.actor.cpp index 467219f..d25060e 100644 --- a/src/QLContext.actor.cpp +++ b/src/QLContext.actor.cpp @@ -144,10 +144,6 @@ ACTOR static Future FDBPlugin_getDescendants(DataKey key, state std::string end = std::move(prefix); end += relEnd; - // if (verboseLogging) - // TraceEvent("BD_getDescendents").detail("from", printable(StringRef(begin)).c_str()).detail("to", - // printable(StringRef(end)).c_str()); - try { state GetRangeLimits limit(GetRangeLimits::ROW_LIMIT_UNLIMITED, 80000); state Future> nextRead = tr->tr->getRange(KeyRangeRef(begin, end), limit); @@ -178,7 +174,7 @@ ACTOR static Future FDBPlugin_getDescendants(DataKey key, throw end_of_stream(); } catch (Error& e) { if (e.code() != error_code_end_of_stream && e.code() != error_code_operation_cancelled) - TraceEvent(SevError, "BD_getDescendants").detail("error", e.what()); + TraceEvent(SevError, "BD_getDescendants").error(e); if (e.code() != error_code_operation_cancelled) output.sendError(e); throw; @@ -325,8 +321,6 @@ struct CompoundIndexPlugin : IndexPlugin, ReferenceCounted, state Future writes_finished = dd->writes_finished.getFuture(); try { - // TraceEvent("BD_doIndexUpdateStart"); - dd->snapshotLock.use(); std::vector>> f_old_values; @@ -433,7 +427,7 @@ struct CompoundIndexPlugin : IndexPlugin, ReferenceCounted, } } catch (Error& e) { - TraceEvent(SevError, "BD_doIndexUpdate").detail("error", e.what()); + TraceEvent(SevError, "BD_doIndexUpdate").error(e); throw; } @@ -475,8 +469,6 @@ struct SimpleIndexPlugin : IndexPlugin, ReferenceCounted, Fas state Reference doc(new QueryContext(self->next, tr, documentPath)); state Future writes_finished = dd->writes_finished.getFuture(); try { - // TraceEvent("BD_doIndexUpdateStart"); - dd->snapshotLock.use(); state std::vector old_values = @@ -536,14 +528,12 @@ struct SimpleIndexPlugin : IndexPlugin, ReferenceCounted, Fas } // clear any existing index entries for (DataValue& v : old_values) { - // fprintf(stderr, "Old value: %s\n", printable(StringRef(v.encode_key_part())).c_str()); DataKey old_key(self->indexPath); old_key.append(v.encode_key_part()).append(documentPath[documentPath.size() - 1]); tr->tr->clear(getFDBKey(old_key)); } // write the new/updated index entries for (DataValue& v : new_values) { - // fprintf(stderr, "New value: %s\n", printable(StringRef(v.encode_key_part())).c_str()); DataKey new_key(self->indexPath); new_key.append(v.encode_key_part()).append(documentPath[documentPath.size() - 1]); if (new_key.byteSize() > DocLayerConstants::INDEX_KEY_LENGTH_LIMIT) { @@ -555,7 +545,7 @@ struct SimpleIndexPlugin : IndexPlugin, ReferenceCounted, Fas tr->tr->set(getFDBKey(new_key), StringRef()); } } catch (Error& e) { - TraceEvent(SevError, "BD_doIndexUpdate").detail("error", e.what()); + TraceEvent(SevError, "BD_doIndexUpdate").error(e); throw; } diff --git a/src/QLPlan.actor.cpp b/src/QLPlan.actor.cpp index 219a0e1..16d8610 100644 --- a/src/QLPlan.actor.cpp +++ b/src/QLPlan.actor.cpp @@ -347,7 +347,7 @@ ACTOR static Future toDocInfo(PlanCheckpoint* checkpoint, throw; } if (e.code() != error_code_end_of_stream) - TraceEvent(SevError, "BD_toDocInfo_error").detail("error", e.what()); + TraceEvent(SevError, "BD_toDocInfo_error").error(e); dis.sendError(e); throw; } @@ -1516,7 +1516,7 @@ ACTOR static Future doSort(PlanCheckpoint* outerCheckpoint, if (e.code() == error_code_end_of_stream) { break; } - TraceEvent(SevError, "BD_runQuery2").detail("error", e.what()); + TraceEvent(SevError, "BD_runQuery2").error(e); throw; } } @@ -1535,7 +1535,7 @@ ACTOR static Future doSort(PlanCheckpoint* outerCheckpoint, ref(new BsonContext(returnProjections[i].getObjectField("doc").getOwned(), false)), -1, Key()))); } } catch (Error& e) { - TraceEvent(SevError, "BD_runQuery2").detail("error", e.what()); + TraceEvent(SevError, "BD_runQuery2").error(e); throw; } innerCheckpoint->stop(); diff --git a/src/QLProjection.actor.cpp b/src/QLProjection.actor.cpp index a7605e7..45d490f 100644 --- a/src/QLProjection.actor.cpp +++ b/src/QLProjection.actor.cpp @@ -105,7 +105,7 @@ ACTOR Future projectDocument_impl(Reference doc, Re return currentPath[0].build().getOwned(); } catch (Error& e) { if (e.code() != error_code_actor_cancelled) - TraceEvent(SevError, "BD_projectDocument").detail("error", e.what()); + TraceEvent(SevError, "BD_projectDocument").error(e); throw; } }