-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Tracing should always log first time statement is executed #89185
Description
This PR turned off plan sampling. I side effect of this being disabled is the first time a statement is executed it is no longer being traced. This causes the contention event shows up in transaction_contention_events table to be empty most of the time. This was verified by running this to revert the flag SET CLUSTER SETTING sql.metrics.statement_details.plan_collection.enabled = true; and the contention event shows up in transaction_contention_events table.
The PR to change the default was reverted, because of the impact. #89020
The logic needs to be fixed so it always traces the first time a statement is executed, so it does not depend on the above feature flag. The issue seems to be in instrumentation.go.
Original PR always traced it: 125f6e6
Refactored here:
https://github.com/cockroachdb/cockroach/commit/06f6874992c8358fef4baada3bec4c5bda359037#diff-a885af4d7f01dd0f13e3ab3[…]59f573ae9c8647aa60e218b0ba24
Jira issue: CRDB-20165