forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
98831: sql: improve how tracing of processors is done on the gateway node r=yuzefovich a=yuzefovich **tracing: make it possible for EventListeners to "consume" the event** This commit extends `Notify` signature with a return argument in order to introduce the notion of "event consumption". Once a listener "consumes" the event, no other listener for the span nor the ancestor spans will be notified about the event. This behavior is needed by the follow-up commit which changes how DistSQL processors examine their traces to pick out their "own" events from the events of their inputs. This also resulted in notifications of the span's listeners be done before the ancestor. Release note: None **execinfra: plumb FlowCtx and processorID into ProcessorSpan method** This commit is mostly a mechanical change to plumb `FlowCtx` object as well as the processor ID into `ProcessorSpan` method. The main goal of this work is to be able to know whether the method is called on the gateway node or not (this will be used by the follow-up commit), but this change also results in unification of how FlowID and ProcessoID tags are set on the tracing span. Release note: None **execstats: collect some stats via EventListeners** This commit changes how contention time, scan stats, and consumed RU information are accumulated by the processors. Previously, we would analyze the trace recording of the processor to pick out all applicable events from the trace and aggregate across all of them. This worked well because currently we always create "detached" spans for all processors (in other words, a contention event attached to the span of one processor will not be seen by the parent processor). However, the following commit will change that for processors on the gateway. Namely, all processors on the gateway will no longer use the detached option. As a result, we need to have a different way to distinguish between events seen by the processor itself versus events seen by the "child" processor. This commit introduces that way via the EventListeners. In particular, it defines three types of listeners (for all kinds of structured events we're interested in), which are then used by all processors. Release note: None **sql: don't propagate spans from local processors as metadata** This commit changes how we create tracing spans for components of the flow on the gateway. Previously, we would always create them with the detached option, and, as a result, we needed to collect the traces and propagate them as metadata to be imported by the DistSQLReceiver into the span of the flow on the gateway. However, this is not necessary to do so on the gateway - we can just let the regular tracing behavior to happen there. The main benefit of this change is that we now preserve the hierarchy of the tracing spans in the gateway flows making them much more understandable when viewing via the jaeger. Perhaps this is also a minor performance improvement since the native trace collection is probably faster than having to import the trace data via the metadata, as was done previously. An additional improvement can be made to create the spans with the detached recording only for the root components of the remote flows. This is left as a TODO for now. Epic: None Release note: None **tracing: Notify EventListeners while holding the span's mutex** This commit addresses an oversight that was introduced in cockroachdb@6a3c0f9 where we made the notifications of the EventListeners done without holding the span's mutex. However, the contract of `WithEventListeners` implies that the callbacks are not called any more after `Finish()` returns, so that commit introduced a bug that is now fixed in this commit. The fix done in this commit is suboptimal though - it introduces an exported method `SetLazyTagLocked` which is not great. The proper fix would be to refactor `TracingAggregator` to avoid setting the lazy tag dynamically, in the event listener callback, but that seems like a non-trivial change, and I'd like to get this commit backported. To avoid introducing more callsites of this `SetLazyTagLocked` method it is marked as "deprecated" and cockroachdb#100438 tracks addressing this piece of the tech debt. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
- Loading branch information
Showing
65 changed files
with
613 additions
and
414 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.