-
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.
Use parent planstate as span end for top level spans (#5)
Top spans end are currently ended at the end of the parent's ExecutorRun while nodes will rely on query instrumentation. This can lead to a situation where a node with nested queries like ProjectSet is shorter than its children. We already use traced_planstate to correctly assign parent for a nested top span. We will keep track of the traced_planstate in the span and use it to when ending the top span.
- Loading branch information
Showing
6 changed files
with
144 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select information_schema._pg_expandarray('{0,1,2}'::int[]); | ||
_pg_expandarray | ||
----------------- | ||
(0,1) | ||
(1,2) | ||
(2,3) | ||
(3 rows) | ||
|
||
SELECT span_operation, deparse_info, parameters, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000001'; | ||
span_operation | deparse_info | parameters | lvl | ||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------+----- | ||
select information_schema._pg_expandarray($1::int[]); | | $1 = '{0,1,2}' | 1 | ||
Planner | | | 2 | ||
ExecutorRun | | | 2 | ||
ProjectSet | | | 3 | ||
Result | | | 4 | ||
select $1[s], s operator(pg_catalog.-) pg_catalog.array_lower($1,$2) operator(pg_catalog.+) $3 from pg_catalog.generate_series(pg_catalog.array_lower($1,$4), pg_catalog.array_upper($1,$5), $6) as g(s) | | $1 = 1, $2 = 1, $3 = 1, $4 = 1, $5 = 1 | 4 | ||
Planner | | | 5 | ||
(7 rows) | ||
|
||
-- +---------------------------------------------+ | ||
-- | A: ProjectSet | | ||
-- ++-----------------+--+----------------+------+ | ||
-- | B: Result | | C: TopSpan | | ||
-- +-----------------+ +-+------------+-+ | ||
-- | D: Planner | | ||
-- +------------+ | ||
SELECT span_id AS span_a_id, | ||
get_epoch(span_start) as span_a_start, | ||
get_epoch(span_end) as span_a_end | ||
from pg_tracing_peek_spans | ||
where trace_id='00000000000000000000000000000001' AND span_operation='ProjectSet' \gset | ||
SELECT span_id AS span_b_id, | ||
get_epoch(span_start) as span_b_start, | ||
get_epoch(span_end) as span_b_end | ||
from pg_tracing_peek_spans | ||
where parent_id =:'span_a_id' and span_operation='Result' \gset | ||
SELECT span_id AS span_c_id, | ||
get_epoch(span_start) as span_c_start, | ||
get_epoch(span_end) as span_c_end | ||
from pg_tracing_peek_spans | ||
where parent_id =:'span_a_id' and span_type='Select query' \gset | ||
SELECT span_id AS span_d_id, | ||
get_epoch(span_start) as span_d_start, | ||
get_epoch(span_end) as span_d_end | ||
from pg_tracing_peek_spans | ||
where parent_id =:'span_c_id' and span_type='Planner' \gset | ||
SELECT :span_a_end >= :span_c_end as project_set_ends_after_nested_top_span; | ||
project_set_ends_after_nested_top_span | ||
---------------------------------------- | ||
t | ||
(1 row) | ||
|
||
-- Clean created spans | ||
CALL clean_spans(); |
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,36 @@ | ||
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select information_schema._pg_expandarray('{0,1,2}'::int[]); | ||
SELECT span_operation, deparse_info, parameters, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000001'; | ||
|
||
-- +---------------------------------------------+ | ||
-- | A: ProjectSet | | ||
-- ++-----------------+--+----------------+------+ | ||
-- | B: Result | | C: TopSpan | | ||
-- +-----------------+ +-+------------+-+ | ||
-- | D: Planner | | ||
-- +------------+ | ||
|
||
SELECT span_id AS span_a_id, | ||
get_epoch(span_start) as span_a_start, | ||
get_epoch(span_end) as span_a_end | ||
from pg_tracing_peek_spans | ||
where trace_id='00000000000000000000000000000001' AND span_operation='ProjectSet' \gset | ||
SELECT span_id AS span_b_id, | ||
get_epoch(span_start) as span_b_start, | ||
get_epoch(span_end) as span_b_end | ||
from pg_tracing_peek_spans | ||
where parent_id =:'span_a_id' and span_operation='Result' \gset | ||
SELECT span_id AS span_c_id, | ||
get_epoch(span_start) as span_c_start, | ||
get_epoch(span_end) as span_c_end | ||
from pg_tracing_peek_spans | ||
where parent_id =:'span_a_id' and span_type='Select query' \gset | ||
SELECT span_id AS span_d_id, | ||
get_epoch(span_start) as span_d_start, | ||
get_epoch(span_end) as span_d_end | ||
from pg_tracing_peek_spans | ||
where parent_id =:'span_c_id' and span_type='Planner' \gset | ||
|
||
SELECT :span_a_end >= :span_c_end as project_set_ends_after_nested_top_span; | ||
|
||
-- Clean created spans | ||
CALL clean_spans(); |
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