Skip to content

stop, kvclient: include DistSender partial batches in traces#67713

Merged
craig[bot] merged 3 commits intocockroachdb:masterfrom
andreimatei:stopper.tracing-first-patches
Jul 20, 2021
Merged

stop, kvclient: include DistSender partial batches in traces#67713
craig[bot] merged 3 commits intocockroachdb:masterfrom
andreimatei:stopper.tracing-first-patches

Conversation

@andreimatei
Copy link
Copy Markdown
Contributor

@andreimatei andreimatei commented Jul 16, 2021

These are the first few patches from #66387 - extracting the non-contentious prefix dealing with DistSender tracing.


Before this patch, since fairly recently, the spans created for
Stopper.RunAsyncTaskEx were not included in the recording of the
caller's span because these spans were created with the ForkSpan(). This
patch adds an option to RunAsyncEx to make the task's span a child of
the caller's, and thus to be included in the caller's recording. This
option is used by the DistSender when sending partial batch requests,
therefore re-including these requests in higher-level traces (as they
used to be).

The reason why async tasks were detached from the caller's span
in #59815 was because of concerns about parent and children spans with
very different lifetimes becoming tied through a trace, delaying the
garbage collection of the whole trace until the last span in it
finishes. This patch gives the caller of RunAsyncTaskEx control over
this behavior; in the particular case of the DistSender, the traces are
not too long lived and the DistSender waits for the async tasks it
spawns to finish. In such circumstances, tying the allocations of the
child spans to the whole trace should be fine.

Release note (general change): A recent release removed parts of some
queries from the debugging traces of those queries. This information
(i.e. the execution of some low-level RPCs) has been re-included in the
traces.

Implement RunLimitedAsyncTask in terms of RunAsyncTask. This also
unifies the behavior w.r.t the provided taskName - one of the two
methods was prepending an "[async]" and the other wasn't.

Release note: None
Add a new stoppper.RunAsyncTaskEx(), which takes an optional semaphore
argument. The new method uses an extensible set of options, as more
options are sure to come in the future.

Release note: None
Before this patch, since fairly recently, the spans created for
Stopper.RunAsyncTask[Ex]() were not included in the recording of the
caller's span because these spans were created with the ForkSpan(). This
patch adds an option to RunAsyncEx to make the task's span a child of
the caller's, and thus to be included in the caller's recording. This
option is used by the DistSender when sending partial batch requests,
therefore re-including these requests in higher-level traces (as they
used to be).

The reason why async tasks were detached from the caller's span
in cockroachdb#59815 was because of concerns about parent and children spans with
very different lifetimes becoming tied through a trace, delaying the
garbage collection of the whole trace until the last span in it
finishes. This patch gives the caller of RunAsyncTaskEx control over
this behavior; in the particular case of the DistSender, the traces are
not too long lived and the DistSender waits for the async tasks it
spawns to finish. In such circumstances, tying the allocations of the
child spans to the whole trace should be fine.

Release note (general change): A recent release removed parts of some
queries from the debugging traces of those queries. This information
(i.e. the execution of some low-level RPCs) has been re-included in the
traces.
@andreimatei andreimatei requested review from aayushshah15 and tbg July 16, 2021 17:15
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm_strong: (though this is the first time I've read some of this code).

Thanks!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @tbg)

Copy link
Copy Markdown
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't do a thorough review since this is code I've already looked at on the original PR.

Reviewed 1 of 1 files at r1, 10 of 10 files at r2, 7 of 7 files at r3.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)

Copy link
Copy Markdown
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 20, 2021

Build succeeded:

@craig craig bot merged commit 1a26f3c into cockroachdb:master Jul 20, 2021
@nvb
Copy link
Copy Markdown
Contributor

nvb commented Aug 6, 2021

@andreimatei how do we feel about backporting this to v21.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants