Add option to enable transaction tracing
This commit is contained in:
parent
ae096e4ba7
commit
18201d6f4f
|
@ -1845,17 +1845,19 @@ TEST_CASE("special-key-space disable tracing") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("FDB_DB_OPTION_DISABLE_TRACING") {
|
||||
fdb_check(fdb_database_set_option(db, FDB_DB_OPTION_DISABLE_TRACING, nullptr, 0));
|
||||
TEST_CASE("FDB_DB_OPTION_TRANSACTION_TRACE_DISABLE") {
|
||||
fdb_check(fdb_database_set_option(db, FDB_DB_OPTION_TRANSACTION_TRACE_DISABLE, nullptr, 0));
|
||||
|
||||
auto value = get_value("\xff\xff/tracing/a/token", /* snapshot */ false, {});
|
||||
REQUIRE(value.has_value());
|
||||
uint64_t token = std::stoul(value.value());
|
||||
CHECK(token == 0);
|
||||
|
||||
fdb_check(fdb_database_set_option(db, FDB_DB_OPTION_TRANSACTION_TRACE_ENABLE, nullptr, 0));
|
||||
}
|
||||
|
||||
TEST_CASE("FDB_DB_OPTION_DISABLE_TRACING enable tracing for transaction") {
|
||||
fdb_check(fdb_database_set_option(db, FDB_DB_OPTION_DISABLE_TRACING, nullptr, 0));
|
||||
TEST_CASE("FDB_DB_OPTION_TRANSACTION_TRACE_DISABLE enable tracing for transaction") {
|
||||
fdb_check(fdb_database_set_option(db, FDB_DB_OPTION_TRANSACTION_TRACE_DISABLE, nullptr, 0));
|
||||
|
||||
fdb::Transaction tr(db);
|
||||
fdb_check(tr.set_option(FDB_TR_OPTION_SPECIAL_KEY_SPACE_ENABLE_WRITES,
|
||||
|
@ -1882,6 +1884,8 @@ TEST_CASE("FDB_DB_OPTION_DISABLE_TRACING enable tracing for transaction") {
|
|||
CHECK(token > 0);
|
||||
break;
|
||||
}
|
||||
|
||||
fdb_check(fdb_database_set_option(db, FDB_DB_OPTION_TRANSACTION_TRACE_ENABLE, nullptr, 0));
|
||||
}
|
||||
|
||||
TEST_CASE("special-key-space tracing get range") {
|
||||
|
@ -1892,7 +1896,6 @@ TEST_CASE("special-key-space tracing get range") {
|
|||
fdb_check(tr.set_option(FDB_TR_OPTION_SPECIAL_KEY_SPACE_ENABLE_WRITES,
|
||||
nullptr, 0));
|
||||
while (1) {
|
||||
tr.set("\xff\xff/tracing/a/token", "true");
|
||||
fdb::KeyValueArrayFuture f1 = tr.get_range(
|
||||
FDB_KEYSEL_FIRST_GREATER_OR_EQUAL(
|
||||
(const uint8_t *)tracingBegin.c_str(),
|
||||
|
@ -1970,10 +1973,7 @@ TEST_CASE("fdb_error_predicate") {
|
|||
CHECK(!fdb_error_predicate(FDB_ERROR_PREDICATE_RETRYABLE_NOT_COMMITTED, 1040)); // proxy_memory_limit_exceeded
|
||||
}
|
||||
|
||||
// Feature not live yet, re-enable when checking if a blocking call is made
|
||||
// from the network thread is live.
|
||||
TEST_CASE("block_from_callback"
|
||||
* doctest::skip(true)) {
|
||||
TEST_CASE("block_from_callback") {
|
||||
fdb::Transaction tr(db);
|
||||
fdb::ValueFuture f1 = tr.get("foo", /*snapshot*/ true);
|
||||
struct Context {
|
||||
|
@ -1988,7 +1988,7 @@ TEST_CASE("block_from_callback"
|
|||
fdb::ValueFuture f2 = context->tr->get("bar", /*snapshot*/ true);
|
||||
fdb_error_t error = f2.block_until_ready();
|
||||
if (error) {
|
||||
CHECK(error == /*blocked_from_network_thread*/ 2025);
|
||||
CHECK(error == /*blocked_from_network_thread*/ 2026);
|
||||
}
|
||||
context->event.set();
|
||||
},
|
||||
|
|
|
@ -319,7 +319,7 @@ public:
|
|||
|
||||
int snapshotRywEnabled;
|
||||
|
||||
bool tracingEnabled;
|
||||
int transactionTracingEnabled;
|
||||
|
||||
Future<Void> logger;
|
||||
Future<Void> throttleExpirer;
|
||||
|
|
|
@ -873,7 +873,7 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionF
|
|||
transactionsResourceConstrained("ResourceConstrained", cc), transactionsThrottled("Throttled", cc),
|
||||
transactionsProcessBehind("ProcessBehind", cc), outstandingWatches(0), latencies(1000), readLatencies(1000),
|
||||
commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), mvCacheInsertLocation(0),
|
||||
healthMetricsLastUpdated(0), detailedHealthMetricsLastUpdated(0), internal(internal), tracingEnabled(true),
|
||||
healthMetricsLastUpdated(0), detailedHealthMetricsLastUpdated(0), internal(internal), transactionTracingEnabled(true),
|
||||
smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT),
|
||||
transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc),
|
||||
specialKeySpace(std::make_unique<SpecialKeySpace>(specialKeys.begin, specialKeys.end, /* test */ false)) {
|
||||
|
@ -1052,7 +1052,7 @@ DatabaseContext::DatabaseContext(const Error& err)
|
|||
transactionsProcessBehind("ProcessBehind", cc), latencies(1000), readLatencies(1000), commitLatencies(1000),
|
||||
GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000),
|
||||
smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT),
|
||||
transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), internal(false), tracingEnabled(true) {}
|
||||
transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), internal(false), transactionTracingEnabled(true) {}
|
||||
|
||||
Database DatabaseContext::create(Reference<AsyncVar<ClientDBInfo>> clientInfo, Future<Void> clientInfoMonitor, LocalityData clientLocality, bool enableLocalityLoadBalance, TaskPriority taskID, bool lockAware, int apiVersion, bool switchable) {
|
||||
return Database( new DatabaseContext( Reference<AsyncVar<Reference<ClusterConnectionFile>>>(), clientInfo, clientInfoMonitor, taskID, clientLocality, enableLocalityLoadBalance, lockAware, true, apiVersion, switchable ) );
|
||||
|
@ -1215,9 +1215,13 @@ void DatabaseContext::setOption( FDBDatabaseOptions::Option option, Optional<Str
|
|||
validateOptionValue(value, false);
|
||||
snapshotRywEnabled--;
|
||||
break;
|
||||
case FDBDatabaseOptions::DISABLE_TRACING:
|
||||
case FDBDatabaseOptions::TRANSACTION_TRACE_ENABLE:
|
||||
validateOptionValue(value, false);
|
||||
tracingEnabled = false;
|
||||
transactionTracingEnabled++;
|
||||
break;
|
||||
case FDBDatabaseOptions::TRANSACTION_TRACE_DISABLE:
|
||||
validateOptionValue(value, false);
|
||||
transactionTracingEnabled--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2704,9 +2708,9 @@ void debugAddTags(Transaction *tr) {
|
|||
|
||||
}
|
||||
|
||||
SpanID generateSpanID(bool tracingEnabled) {
|
||||
SpanID generateSpanID(int transactionTracingEnabled) {
|
||||
UID uid = deterministicRandom()->randomUniqueID();
|
||||
if (tracingEnabled) {
|
||||
if (transactionTracingEnabled > 0) {
|
||||
return SpanID(uid.first(), uid.second());
|
||||
} else {
|
||||
return SpanID(uid.first(), 0);
|
||||
|
@ -2719,7 +2723,7 @@ Transaction::Transaction()
|
|||
span(info.spanID, "Transaction"_loc) {}
|
||||
|
||||
Transaction::Transaction(Database const& cx)
|
||||
: cx(cx), info(cx->taskID, generateSpanID(cx->tracingEnabled)), backoff(CLIENT_KNOBS->DEFAULT_BACKOFF),
|
||||
: cx(cx), info(cx->taskID, generateSpanID(cx->transactionTracingEnabled)), backoff(CLIENT_KNOBS->DEFAULT_BACKOFF),
|
||||
committedVersion(invalidVersion), versionstampPromise(Promise<Standalone<StringRef>>()), options(cx), numErrors(0),
|
||||
trLogInfo(createTrLogInfoProbabilistically(cx)), tr(info.spanID), span(info.spanID, "Transaction"_loc) {
|
||||
if (DatabaseContext::debugUseTags) {
|
||||
|
|
|
@ -182,7 +182,9 @@ description is not currently required but encouraged.
|
|||
<Option name="transaction_include_port_in_address" code="505"
|
||||
description="Addresses returned by get_addresses_for_key include the port when enabled. As of api version 630, this option is enabled by default and setting this has no effect."
|
||||
defaultFor="23"/>
|
||||
<Option name="disable_tracing" code="600"
|
||||
<Option name="transaction_trace_enable" code="600"
|
||||
description="Enable tracing for all transactions. This is the default." />
|
||||
<Option name="transaction_trace_disable" code="601"
|
||||
description="Disable tracing for all transactions." />
|
||||
</Scope>
|
||||
|
||||
|
|
Loading…
Reference in New Issue