release-23.2: sql: add probabilistic transaction tracing #149497
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #148542.
/cc @cockroachdb/release
Previously, tracing transactions in CRDB could be enabled using a single cluster setting:
sql.trace.txn.enable_threshold, which, if it was non-zero, would enable tracing on all transactions and only keep and emit the traces for transactions which exceeded the execution time threshold. This has proven to be difficult to use as it reuquires paying tracing cost on the entire workload.This change modifies the transaction tracing capabilities of CRDB to incorporate a sample rate. A new cluster setting is introduced, named
sql.trace.txn.sample_ratewhich is zero by default. When set to a positive number between 0 and 1, this will set the probability of a transaction having tracing enabled.For tracing to emit a trace for a transaction, both settings will now need to be set and will need to both trigger for successful output to the
SQL_EXEClogging channel. Transactions first pass through the sample rate filter which governs whether a trace is captured, then they will be evaluated through theenable_thresholdwhich governs whether the trace is emitted to the logs.Epic: None
Resolves: CRDB-51662
Release note (ops change, sql change): In order to selectively capture traces for transactions running in an active workload without haing to capture them via statement diagnostic bundles, customers can now use the
sql.trace.txn.sample_ratecluster setting to enable tracing for a fraction of their workload. Thesql.trace.txn.enable_thresholdwill still need to be set to a positive value to provide a filter for how slow a transaction needs to be after being sampled to merit emitting a trace. Traces are emitted to theSQL_EXEClogging channel.