This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 142
CORTX-33564: Fixed panic in rpc_session_cancelled() due to session state #1969
Merged
Conversation
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
yatin-mahajan
requested review from
mehjoshi,
madhavemuri,
nikitadanilov,
yeshpal-jain-seagate,
huanghua78,
andriytk,
siningwuseagate,
vidyadhar-pinglikar,
shashank-parulekar,
nkommuri,
sg-shankar,
ivan-alekhin,
sergey-shilov and
rkothiya
as code owners
July 7, 2022 16:05
huanghua78
reviewed
Jul 8, 2022
ivan-alekhin
suggested changes
Jul 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch does not address the root cause: unprotected access to sm state. The patch, essentially, disables the preconditions. It means the situation described in the PR description is still possible: session is getting canceled while another thread is trying to terminate it. However, with this patch we won't see it because preconditions were removed. We will have a hidden race condition instead.
Please take a look at the comments.
Also, please include the backtraces of the issue into the commit message.
madhavemuri
reviewed
Jul 11, 2022
madhavemuri
approved these changes
Jul 11, 2022
ivan-alekhin
approved these changes
Jul 11, 2022
Problem: While session was getting canceled some other thread is trying to terminate that session and moves session state to M0_RPC_SESSION_TERMINATING, which lead to hit assert M0_POST(session->s_sm.sm_state == M0_RPC_SESSION_IDLE) in rpc_session_cancel(). Solution: It is possible that some other thread is trying to terminate the same session while session is getting cancelled, only the IDLE/BUSY sessions are allowed to cancel. Updated pre check to return from m0_rpc_cancel instead of panic/assert. Also replaced M0_POST()/assert with proper debug log. Signed-off-by: Yatin Mahajan <yatin.mahajan@seagate.com>
Problem: While session was getting canceled some other thread is trying to terminate that session and moves session state to M0_RPC_SESSION_TERMINATING, which lead to hit assert M0_POST(session->s_sm.sm_state == M0_RPC_SESSION_IDLE) in rpc_session_cancel(). Seagate#5 in m0_arch_panic (c=c@entry=0x7f7276a91b40 <__pctx.14289>, ap=ap@entry=0x7f7268c05ce0) at lib/user_space/uassert.c:131 Seagate#6 in m0_panic (ctx=ctx@entry=0x7f7276a91b40 <__pctx.14289>) at lib/assert.c:52 Seagate#7 in m0_rpc_session_cancel (session=session@entry=0x56283c7c13d8) at rpc/session.c:863 Seagate#8 in m0_rpc_conn_sessions_cancel (conn=conn@entry=0x56283c7c1030) at rpc/conn.c:1333 Seagate#9 in rpc_conn__on_service_event_cb (clink=<optimized out>) at rpc/conn.c:1364 Seagate#10 in clink_signal (clink=clink@entry=0x56283c7c12c0) at lib/chan.c:135 Seagate#11 in chan_signal_nr (chan=chan@entry=0x56283c6a8768, nr=1) at lib/chan.c:154 Seagate#12 in m0_chan_broadcast (chan=chan@entry=0x56283c6a8768) at lib/chan.c:174 Seagate#13 in ha_state_accept (ignore_same_state=1, note=0x7f7268c06060, confc=0x56283816b028) at ha/note.c:18 Solution: It is possible that some other thread is trying to terminate the same session while session is getting cancelled, only the IDLE/BUSY sessions are allowed to cancel. Updated pre check to return from m0_rpc_cancel instead of panic/assert. Also replaced M0_POST()/assert with proper debug log. Signed-off-by: Yatin Mahajan <yatin.mahajan@seagate.com>
yatin-mahajan
force-pushed
the
CORTX-33564
branch
from
July 12, 2022 06:45
70df107
to
2b01852
Compare
yeshpal-jain-seagate
approved these changes
Jul 18, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
While session was getting canceled some other thread is trying to terminate
that session and moves session state to M0_RPC_SESSION_TERMINATING, which
lead to hit assert M0_POST(session->s_sm.sm_state == M0_RPC_SESSION_IDLE)
in rpc_session_cancel().
#5 in m0_arch_panic (c=c@entry=0x7f7276a91b40 <__pctx.14289>, ap=ap@entry=0x7f7268c05ce0) at lib/user_space/uassert.c:131
#6 in m0_panic (ctx=ctx@entry=0x7f7276a91b40 <__pctx.14289>) at lib/assert.c:52
#7 in m0_rpc_session_cancel (session=session@entry=0x56283c7c13d8) at rpc/session.c:863
#8 in m0_rpc_conn_sessions_cancel (conn=conn@entry=0x56283c7c1030) at rpc/conn.c:1333
#9 in rpc_conn__on_service_event_cb (clink=) at rpc/conn.c:1364
#10 in clink_signal (clink=clink@entry=0x56283c7c12c0) at lib/chan.c:135
#11 in chan_signal_nr (chan=chan@entry=0x56283c6a8768, nr=1) at lib/chan.c:154
#12 in m0_chan_broadcast (chan=chan@entry=0x56283c6a8768) at lib/chan.c:174
#13 in ha_state_accept (ignore_same_state=1, note=0x7f7268c06060, confc=0x56283816b028) at ha/note.c:18
Solution:
It is possible that some other thread is trying to terminate the same session
while session is getting cancelled, only the IDLE/BUSY sessions are allowed to
cancel. Updated pre check to return from m0_rpc_cancel instead of panic/assert.
Also replaced M0_POST()/assert with proper debug log.
Signed-off-by: Yatin Mahajan yatin.mahajan@seagate.com
Problem Statement
Design
Coding
Checklist for Author
Testing
Checklist for Author
Impact Analysis
Checklist for Author/Reviewer/GateKeeper
Review Checklist
Checklist for Author
Documentation
Checklist for Author