-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On parallel query, save the tracecontext in a shared memory. Parallel worker will be able to pull the tracecontext from it and generate spans on their own.
- Loading branch information
Showing
7 changed files
with
321 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
begin; | ||
-- encourage use of parallel plans | ||
set local parallel_setup_cost=0; | ||
set local parallel_tuple_cost=0; | ||
set local min_parallel_table_scan_size=0; | ||
set local max_parallel_workers_per_gather=2; | ||
-- Trace parallel queries | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select 1 from pg_class limit 1; | ||
?column? | ||
---------- | ||
1 | ||
(1 row) | ||
|
||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ select 2 from pg_class limit 1; | ||
?column? | ||
---------- | ||
2 | ||
(1 row) | ||
|
||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000003-00'*/ select 3 from pg_class limit 1; | ||
?column? | ||
---------- | ||
3 | ||
(1 row) | ||
|
||
-- Try with parallel tracing disabled | ||
set local pg_tracing.trace_parallel_workers = false; | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000004-0000000000000004-01'*/ select 4 from pg_class limit 1; | ||
?column? | ||
---------- | ||
4 | ||
(1 row) | ||
|
||
commit; | ||
-- Get root top span id | ||
SELECT span_id as root_span_id from pg_tracing_peek_spans where span_type='Select query' and trace_id='00000000000000000000000000000001' and parent_id='0000000000000001' \gset | ||
-- Get executor top span id | ||
SELECT span_id as executor_span_id from pg_tracing_peek_spans where span_operation='ExecutorRun' and trace_id='00000000000000000000000000000001' and parent_id=:'root_span_id' \gset | ||
-- Check the select spans that are attached to the root top span | ||
SELECT trace_id, span_type, span_operation from pg_tracing_peek_spans where span_type='Select query' and parent_id=:'executor_span_id' order by span_operation; | ||
trace_id | span_type | span_operation | ||
----------------------------------+--------------+---------------- | ||
00000000000000000000000000000001 | Select query | Worker 0 | ||
00000000000000000000000000000001 | Select query | Worker 1 | ||
(2 rows) | ||
|
||
-- Check generated trace_id | ||
SELECT trace_id from pg_tracing_peek_spans group by trace_id; | ||
trace_id | ||
---------------------------------- | ||
00000000000000000000000000000001 | ||
00000000000000000000000000000004 | ||
00000000000000000000000000000002 | ||
(3 rows) | ||
|
||
-- Check number of executor spans | ||
SELECT count(*) from pg_tracing_consume_spans where span_type='Executor'; | ||
count | ||
------- | ||
7 | ||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
begin; | ||
-- encourage use of parallel plans | ||
set local parallel_setup_cost=0; | ||
set local parallel_tuple_cost=0; | ||
set local min_parallel_table_scan_size=0; | ||
set local max_parallel_workers_per_gather=2; | ||
|
||
-- Trace parallel queries | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select 1 from pg_class limit 1; | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ select 2 from pg_class limit 1; | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000003-00'*/ select 3 from pg_class limit 1; | ||
|
||
-- Try with parallel tracing disabled | ||
set local pg_tracing.trace_parallel_workers = false; | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000004-0000000000000004-01'*/ select 4 from pg_class limit 1; | ||
commit; | ||
|
||
-- Get root top span id | ||
SELECT span_id as root_span_id from pg_tracing_peek_spans where span_type='Select query' and trace_id='00000000000000000000000000000001' and parent_id='0000000000000001' \gset | ||
-- Get executor top span id | ||
SELECT span_id as executor_span_id from pg_tracing_peek_spans where span_operation='ExecutorRun' and trace_id='00000000000000000000000000000001' and parent_id=:'root_span_id' \gset | ||
|
||
-- Check the select spans that are attached to the root top span | ||
SELECT trace_id, span_type, span_operation from pg_tracing_peek_spans where span_type='Select query' and parent_id=:'executor_span_id' order by span_operation; | ||
|
||
-- Check generated trace_id | ||
SELECT trace_id from pg_tracing_peek_spans group by trace_id; | ||
|
||
-- Check number of executor spans | ||
SELECT count(*) from pg_tracing_consume_spans where span_type='Executor'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.