Skip to content

Commit

Permalink
sql: add crdb_internal.{node,cluster}_txn_execution_insights
Browse files Browse the repository at this point in the history
Closes cockroachdb#93075

This commit adds 2 new virtual tables displaying execution
insights for transaction.
- crdb_internal.cluster_txn_execution_insights
- crdb_internal.node_txn_execution_insights

Release note (sql change):
2 new virtual tables displaying execution insights for transaction:
- crdb_internal.cluster_txn_execution_insights
- crdb_internal.node_txn_execution_insights
  • Loading branch information
xinhaoz committed Jan 17, 2023
1 parent 6116ab4 commit f94eeba
Show file tree
Hide file tree
Showing 22 changed files with 1,328 additions and 1,008 deletions.
12 changes: 12 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ crdb_internal cluster_settings table admin NULL NULL
crdb_internal cluster_statement_statistics table admin NULL NULL
crdb_internal cluster_transaction_statistics table admin NULL NULL
crdb_internal cluster_transactions table admin NULL NULL
crdb_internal cluster_txn_execution_insights table admin NULL NULL
crdb_internal create_function_statements table admin NULL NULL
crdb_internal create_schema_statements table admin NULL NULL
crdb_internal create_statements table admin NULL NULL
Expand Down Expand Up @@ -79,6 +80,7 @@ crdb_internal node_sessions table admin NULL NULL
crdb_internal node_statement_statistics table admin NULL NULL
crdb_internal node_transaction_statistics table admin NULL NULL
crdb_internal node_transactions table admin NULL NULL
crdb_internal node_txn_execution_insights table admin NULL NULL
crdb_internal node_txn_stats table admin NULL NULL
crdb_internal partitions table admin NULL NULL
crdb_internal pg_catalog_table_is_implemented table admin NULL NULL
Expand Down Expand Up @@ -307,6 +309,16 @@ SELECT * FROM crdb_internal.node_inflight_trace_spans WHERE span_id < 0
----
trace_id parent_span_id span_id goroutine_id finished start_time duration operation

query TTTBTTTTTIITITTTTT colnames
SELECT * FROM crdb_internal.cluster_txn_execution_insights WHERE query = ''
----
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids

query TTTBTTTTTIITITTTTT colnames
SELECT * FROM crdb_internal.node_txn_execution_insights WHERE query = ''
----
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids

query ITTI
SELECT range_id, start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
----
Expand Down
6 changes: 6 additions & 0 deletions pkg/cli/testdata/zip/partial1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_settings... writing output: debug/crdb_internal.cluster_settings.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_transactions... writing output: debug/crdb_internal.cluster_transactions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights... writing output: debug/crdb_internal.cluster_txn_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.default_privileges... writing output: debug/crdb_internal.default_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
Expand Down Expand Up @@ -93,6 +94,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 1] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/1/crdb_internal.node_statement_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/1/crdb_internal.node_transaction_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/1/crdb_internal.node_transactions.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/1/crdb_internal.node_txn_execution_insights.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/1/crdb_internal.node_txn_stats.txt... done
[node 1] requesting data for debug/nodes/1/details... received response... converting to JSON... writing binary output: debug/nodes/1/details.json... done
[node 1] requesting data for debug/nodes/1/gossip... received response... converting to JSON... writing binary output: debug/nodes/1/gossip.json... done
Expand Down Expand Up @@ -221,6 +223,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 2] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/2/crdb_internal.node_transactions.txt...
[node 2] retrieving SQL data for crdb_internal.node_transactions: last request failed: dial tcp ...
[node 2] retrieving SQL data for crdb_internal.node_transactions: creating error output: debug/nodes/2/crdb_internal.node_transactions.txt.err.txt... done
[node 2] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/2/crdb_internal.node_txn_execution_insights.txt...
[node 2] retrieving SQL data for crdb_internal.node_txn_execution_insights: last request failed: dial tcp ...
[node 2] retrieving SQL data for crdb_internal.node_txn_execution_insights: creating error output: debug/nodes/2/crdb_internal.node_txn_execution_insights.txt.err.txt... done
[node 2] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/2/crdb_internal.node_txn_stats.txt...
[node 2] retrieving SQL data for crdb_internal.node_txn_stats: last request failed: dial tcp ...
[node 2] retrieving SQL data for crdb_internal.node_txn_stats: creating error output: debug/nodes/2/crdb_internal.node_txn_stats.txt.err.txt... done
Expand Down Expand Up @@ -274,6 +279,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 3] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/3/crdb_internal.node_statement_statistics.txt... done
[node 3] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/3/crdb_internal.node_transaction_statistics.txt... done
[node 3] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/3/crdb_internal.node_transactions.txt... done
[node 3] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/3/crdb_internal.node_txn_execution_insights.txt... done
[node 3] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/3/crdb_internal.node_txn_stats.txt... done
[node 3] requesting data for debug/nodes/3/details... received response... converting to JSON... writing binary output: debug/nodes/3/details.json... done
[node 3] requesting data for debug/nodes/3/gossip... received response... converting to JSON... writing binary output: debug/nodes/3/gossip.json... done
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/testdata/zip/partial1_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_settings... writing output: debug/crdb_internal.cluster_settings.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_transactions... writing output: debug/crdb_internal.cluster_transactions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights... writing output: debug/crdb_internal.cluster_txn_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.default_privileges... writing output: debug/crdb_internal.default_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
Expand Down Expand Up @@ -93,6 +94,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 1] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/1/crdb_internal.node_statement_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/1/crdb_internal.node_transaction_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/1/crdb_internal.node_transactions.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/1/crdb_internal.node_txn_execution_insights.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/1/crdb_internal.node_txn_stats.txt... done
[node 1] requesting data for debug/nodes/1/details... received response... converting to JSON... writing binary output: debug/nodes/1/details.json... done
[node 1] requesting data for debug/nodes/1/gossip... received response... converting to JSON... writing binary output: debug/nodes/1/gossip.json... done
Expand Down Expand Up @@ -186,6 +188,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 3] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/3/crdb_internal.node_statement_statistics.txt... done
[node 3] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/3/crdb_internal.node_transaction_statistics.txt... done
[node 3] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/3/crdb_internal.node_transactions.txt... done
[node 3] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/3/crdb_internal.node_txn_execution_insights.txt... done
[node 3] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/3/crdb_internal.node_txn_stats.txt... done
[node 3] requesting data for debug/nodes/3/details... received response... converting to JSON... writing binary output: debug/nodes/3/details.json... done
[node 3] requesting data for debug/nodes/3/gossip... received response... converting to JSON... writing binary output: debug/nodes/3/gossip.json... done
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/testdata/zip/partial2
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_settings... writing output: debug/crdb_internal.cluster_settings.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_transactions... writing output: debug/crdb_internal.cluster_transactions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights... writing output: debug/crdb_internal.cluster_txn_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.default_privileges... writing output: debug/crdb_internal.default_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
Expand Down Expand Up @@ -93,6 +94,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 1] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/1/crdb_internal.node_statement_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/1/crdb_internal.node_transaction_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/1/crdb_internal.node_transactions.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/1/crdb_internal.node_txn_execution_insights.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/1/crdb_internal.node_txn_stats.txt... done
[node 1] requesting data for debug/nodes/1/details... received response... converting to JSON... writing binary output: debug/nodes/1/details.json... done
[node 1] requesting data for debug/nodes/1/gossip... received response... converting to JSON... writing binary output: debug/nodes/1/gossip.json... done
Expand Down Expand Up @@ -185,6 +187,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 3] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/3/crdb_internal.node_statement_statistics.txt... done
[node 3] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/3/crdb_internal.node_transaction_statistics.txt... done
[node 3] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/3/crdb_internal.node_transactions.txt... done
[node 3] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/3/crdb_internal.node_txn_execution_insights.txt... done
[node 3] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/3/crdb_internal.node_txn_stats.txt... done
[node 3] requesting data for debug/nodes/3/details... received response... converting to JSON... writing binary output: debug/nodes/3/details.json... done
[node 3] requesting data for debug/nodes/3/gossip... received response... converting to JSON... writing binary output: debug/nodes/3/gossip.json... done
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/testdata/zip/testzip
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_settings... writing output: debug/crdb_internal.cluster_settings.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_transactions... writing output: debug/crdb_internal.cluster_transactions.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights... writing output: debug/crdb_internal.cluster_txn_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.default_privileges... writing output: debug/crdb_internal.default_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
Expand Down Expand Up @@ -96,6 +97,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node 1] retrieving SQL data for crdb_internal.node_statement_statistics... writing output: debug/nodes/1/crdb_internal.node_statement_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transaction_statistics... writing output: debug/nodes/1/crdb_internal.node_transaction_statistics.txt... done
[node 1] retrieving SQL data for crdb_internal.node_transactions... writing output: debug/nodes/1/crdb_internal.node_transactions.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights... writing output: debug/nodes/1/crdb_internal.node_txn_execution_insights.txt... done
[node 1] retrieving SQL data for crdb_internal.node_txn_stats... writing output: debug/nodes/1/crdb_internal.node_txn_stats.txt... done
[node 1] requesting data for debug/nodes/1/details... received response... converting to JSON... writing binary output: debug/nodes/1/details.json... done
[node 1] requesting data for debug/nodes/1/gossip... received response... converting to JSON... writing binary output: debug/nodes/1/gossip.json... done
Expand Down
12 changes: 12 additions & 0 deletions pkg/cli/testdata/zip/testzip_concurrent
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ zip
[cluster] retrieving SQL data for crdb_internal.cluster_transactions...
[cluster] retrieving SQL data for crdb_internal.cluster_transactions: done
[cluster] retrieving SQL data for crdb_internal.cluster_transactions: writing output: debug/crdb_internal.cluster_transactions.txt...
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights...
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights: done
[cluster] retrieving SQL data for crdb_internal.cluster_txn_execution_insights: writing output: debug/crdb_internal.cluster_txn_execution_insights.txt...
[cluster] retrieving SQL data for crdb_internal.default_privileges...
[cluster] retrieving SQL data for crdb_internal.default_privileges: done
[cluster] retrieving SQL data for crdb_internal.default_privileges: writing output: debug/crdb_internal.default_privileges.txt...
Expand Down Expand Up @@ -337,6 +340,9 @@ zip
[node 1] retrieving SQL data for crdb_internal.node_transactions...
[node 1] retrieving SQL data for crdb_internal.node_transactions: done
[node 1] retrieving SQL data for crdb_internal.node_transactions: writing output: debug/nodes/1/crdb_internal.node_transactions.txt...
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights...
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights: done
[node 1] retrieving SQL data for crdb_internal.node_txn_execution_insights: writing output: debug/nodes/1/crdb_internal.node_txn_execution_insights.txt...
[node 1] retrieving SQL data for crdb_internal.node_txn_stats...
[node 1] retrieving SQL data for crdb_internal.node_txn_stats: done
[node 1] retrieving SQL data for crdb_internal.node_txn_stats: writing output: debug/nodes/1/crdb_internal.node_txn_stats.txt...
Expand Down Expand Up @@ -664,6 +670,9 @@ zip
[node 2] retrieving SQL data for crdb_internal.node_transactions...
[node 2] retrieving SQL data for crdb_internal.node_transactions: done
[node 2] retrieving SQL data for crdb_internal.node_transactions: writing output: debug/nodes/2/crdb_internal.node_transactions.txt...
[node 2] retrieving SQL data for crdb_internal.node_txn_execution_insights...
[node 2] retrieving SQL data for crdb_internal.node_txn_execution_insights: done
[node 2] retrieving SQL data for crdb_internal.node_txn_execution_insights: writing output: debug/nodes/2/crdb_internal.node_txn_execution_insights.txt...
[node 2] retrieving SQL data for crdb_internal.node_txn_stats...
[node 2] retrieving SQL data for crdb_internal.node_txn_stats: done
[node 2] retrieving SQL data for crdb_internal.node_txn_stats: writing output: debug/nodes/2/crdb_internal.node_txn_stats.txt...
Expand Down Expand Up @@ -991,6 +1000,9 @@ zip
[node 3] retrieving SQL data for crdb_internal.node_transactions...
[node 3] retrieving SQL data for crdb_internal.node_transactions: done
[node 3] retrieving SQL data for crdb_internal.node_transactions: writing output: debug/nodes/3/crdb_internal.node_transactions.txt...
[node 3] retrieving SQL data for crdb_internal.node_txn_execution_insights...
[node 3] retrieving SQL data for crdb_internal.node_txn_execution_insights: done
[node 3] retrieving SQL data for crdb_internal.node_txn_execution_insights: writing output: debug/nodes/3/crdb_internal.node_txn_execution_insights.txt...
[node 3] retrieving SQL data for crdb_internal.node_txn_stats...
[node 3] retrieving SQL data for crdb_internal.node_txn_stats: done
[node 3] retrieving SQL data for crdb_internal.node_txn_stats: writing output: debug/nodes/3/crdb_internal.node_txn_stats.txt...
Expand Down
Loading

0 comments on commit f94eeba

Please sign in to comment.