Skip to content

kvserver: improve the delegate snapshot code#82490

Merged
craig[bot] merged 5 commits intocockroachdb:masterfrom
andreimatei:fix-delegate-snapshot
Jun 8, 2022
Merged

kvserver: improve the delegate snapshot code#82490
craig[bot] merged 5 commits intocockroachdb:masterfrom
andreimatei:fix-delegate-snapshot

Conversation

@andreimatei
Copy link
Copy Markdown
Contributor

See individual commits.

@andreimatei andreimatei requested review from aayushshah15 and nvb June 6, 2022 21:37
@andreimatei andreimatei requested a review from a team as a code owner June 6, 2022 21:37
@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.

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


pkg/kv/kvserver/raft_transport.go line 468 at r4 (raw file):

// RaftSnapshot handles incoming streaming snapshot requests.
func (t *RaftTransport) RaftSnapshot(stream MultiRaft_RaftSnapshotServer) error {

We should update this handler as well right?

A span created for the handling of the DelegateRaftSnapshot RPC was
sometimes leaked when the RPC was racing with the server shutdown. This
is because the resposibility of closing this span was delegated over
several layers, and two of the layers were not closing it when they were
failing to create a stopper task.
The span in question was also created with the wrong name because of
copy-pasta. Also, the span is generally unnecessary; I'll clean up in a
further patch.

Fixes cockroachdb#80838
Fixes cockroachdb#80822

Release note: None
@andreimatei andreimatei force-pushed the fix-delegate-snapshot branch from 99442d6 to 6115998 Compare June 8, 2022 19:59
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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15 and @nvanbenschoten)


pkg/kv/kvserver/raft_transport.go line 468 at r4 (raw file):

Previously, aayushshah15 (Aayush Shah) wrote…

We should update this handler as well right?

done

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:

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

The DelegateRaftSnapshot RPC handler was creating a tracing span even
though a similar one had already been created by the gRPC tracing
interceptor.

Release note: None
Store.HandleDelegatedSnapshot was operating in a Task even though its
one caller is also creating a Task.

Release note: None
The handler for these RPC was spawning off work asynchronously, and
waiting on it to be done, while also waiting on stopped shutdown. At the
same time, it was also configuring the ctx to be canceled on stopper
quiescence. As far as I can tell, the work in question responds to
cancelation, so having the sender separately wait for server shutdown
was not necessary. Even more, I don't think it was valid to return from
the handler while the RPC's stream is in use by an another goroutine
(although gRPC does not document these contracts well).

This patch makes the RPC handler run synchronously. No (synchronous)
stopper task is necessary since all the RPCs get one through a handler.

Release note: None
@andreimatei andreimatei force-pushed the fix-delegate-snapshot branch from 6115998 to 72986a8 Compare June 8, 2022 20:42
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! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @aayushshah15 and @nvanbenschoten)

@craig craig bot merged commit 7d365bc into cockroachdb:master Jun 8, 2022
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 8, 2022

Build succeeded:

@andreimatei andreimatei deleted the fix-delegate-snapshot branch June 9, 2022 16:02
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.

3 participants