Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc/transport: fix temporary dispatch loop stalls #11023

Merged
merged 4 commits into from
Jun 3, 2023

Conversation

bharathv
Copy link
Contributor

@bharathv bharathv commented May 25, 2023

Currently the way the code is structured can result in temporary
dispatch stalls timing out a bunch of requests.

Consider a request queue of sequence numbers [5, 6, 7, 8]

Lets assume seq=6 dispatch got delayed. This can happen if timeout is
low or there is an unknown delay by the scheduler (eg: debug builds).

_last_seq=4, queue = [5, 7, 8] - 5 is dispatched right away
_last_seq=5, queue = [7,8] -- out of order.

Dispatch of 7, 8 doesn't happen right away due to out of order sequence
and we never do a dispatch with seq=6 because we detect it already
timed out.

Now it takes a new RPC request to clear the stalled queue but
that may not happen for a while (eg: until the queued RPCs are timed out) and
meanwhile seq=7/8 timeout for no fault of theirs.

This patch does two main things.

  • Consolidates _last_seq tracking. Currently it is not monotonic and can
    jump all over the place. This is confusing. Now we only update it in a
    centralized place in dispatch_send().

  • ^^ Requires that dispatch_send() is called in all cases which also
    avoids dispatch loop stalls. For example, a timed out request will clear
    the stalled queue right away (which is not the case before).

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.1.x
  • v22.3.x
  • v22.2.x

Release Notes

  • none

src/v/rpc/transport.cc Outdated Show resolved Hide resolved
@bharathv bharathv requested a review from dotnwat May 25, 2023 18:13
Comment on lines 208 to 209
from_now(timing.memory_reserved_at),
from_now(timing.enqueued_at),
Copy link
Member

Choose a reason for hiding this comment

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

are enqueue and memory reserved out of order?

@@ -204,6 +205,7 @@ transport::make_response_handler(
_correlations.size(),
from_now(
timing.timeout.timeout_at() - timing.timeout.timeout_period),
from_now(timing.memory_reserved_at),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should go after enqueued_at, just noticed.. will fix .

Incase RPCs are timing out due to memory pressure (unlikely given we do
not set a small limit to the semaphore but just in case).
.. to track the sequence of dispatches.
@bharathv
Copy link
Contributor Author

bharathv commented Jun 1, 2023

Moving to draft as I do more ci-repeat runs..I folded the dispatch loop stall fix into this PR.

@bharathv bharathv marked this pull request as draft June 1, 2023 19:38
Currently the way the code is structured can result in temporary
dispatch stalls timing out a bunch of requests.

Consider a request queue of sequence numbers [5, 6, 7, 8]

Lets assume seq=6 dispatch got delayed. This can happen if timeout is
low or there is an unknown delay by the scheduler (eg: debug builds).

_last_seq=4, queue = [5, 7, 8] - 5 is dispatched right away
_last_seq=5, queue = [7,8] -- out of order.

Dispatch of 7, 8 doesn't happen right away due to out of order sequence
and we never do a dispatch with seq=6 because we detect it already
timed out.

Now it takes a new RPC request to clear the stalled queue but
they may not happen for a while as most of these are timer based and
meanwhile seq=7/8 timeout for no fault of theirs.

This patch does two main things.

* Consolidates _last_seq tracking. Currently it is not monotonic and can
jump all over the place. This is confusing. Now we only update it in a
centralized place in dispatch_send().

* ^^ Requires that dispatch_send() is called in all cases which also
avoids dispatch loop stalls. For example, a timed out request will clear
the stalled queue right away (which is not the case before).
@bharathv
Copy link
Contributor Author

bharathv commented Jun 1, 2023

/ci-repeat 5
debug
skip-units

@bharathv bharathv changed the title rpc/transport: additional debug information for spurious timeouts rpc/transport: fix temporary dispatch loop stalls Jun 2, 2023
@bharathv bharathv requested a review from dotnwat June 2, 2023 01:53
@bharathv bharathv marked this pull request as ready for review June 2, 2023 01:54
@bharathv
Copy link
Contributor Author

bharathv commented Jun 2, 2023

repeat-5 debug failures are all known flaky issues currently happening with debug builds.

@dotnwat dotnwat requested a review from graphcareful June 2, 2023 05:10
@bharathv bharathv self-assigned this Jun 2, 2023
@dotnwat
Copy link
Member

dotnwat commented Jun 2, 2023

Following up here from out-of-band conversation:

q: do we have any rpc users that depend on ordered delivery?
a: dunno, probably not. but there is that thing with optimization related to in-order delivery of raft messages
q: does this pr change delivery order?
a: messages may be dropped (but that happened before, too), so no?
q: is that accurate, are there other concerns?

i guess the important thing is to fully understand if there are material differences for delivery order?

cc @mmaslankaprv @bharathv

@bharathv
Copy link
Contributor Author

bharathv commented Jun 2, 2023

i guess the important thing is to fully understand if there are material differences for delivery order?

I think there is no change.. out of order messages are always possible with timeouts eg: head of the queue times out and then the next RPC that depends on it is successfully dispatched. AIUI in order delivery is done on a best effort basis as a performance optimization but we have checks in the raft layer for correctness.

@dotnwat
Copy link
Member

dotnwat commented Jun 2, 2023

Thanks @bharathv

@bharathv
Copy link
Contributor Author

bharathv commented Jun 2, 2023

/ci-repeat 1

@dotnwat dotnwat merged commit 68d67a5 into redpanda-data:dev Jun 3, 2023
@vbotbuildovich
Copy link
Collaborator

/backport v23.1.x

@dotnwat
Copy link
Member

dotnwat commented Jun 3, 2023

Did we see this issue reported in 23.1.x?

@bharathv
Copy link
Contributor Author

bharathv commented Jun 5, 2023

Did we see this issue reported in 23.1.x?

No not really.. I closed the backport, we can revisit it later.

@bharathv bharathv deleted the transport_debug branch June 5, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants