run the Gx RAR apply as an async procedure - #67
Merged
Conversation
This was referenced Jul 26, 2026
next-nf
force-pushed
the
async-terminate-step4
branch
from
July 27, 2026 11:44
7a44782 to
723e0b4
Compare
next-nf
force-pushed
the
async-rar-apply-modify
branch
from
July 27, 2026 11:44
e3a9c81 to
496b12c
Compare
next-nf
force-pushed
the
async-terminate-step4
branch
from
July 27, 2026 12:16
723e0b4 to
44d125a
Compare
next-nf
force-pushed
the
async-rar-apply-modify
branch
from
July 27, 2026 12:16
496b12c to
04cd3ab
Compare
next-nf
force-pushed
the
async-terminate-step4
branch
from
July 27, 2026 12:23
44d125a to
a826616
Compare
next-nf
force-pushed
the
async-rar-apply-modify
branch
from
July 27, 2026 12:23
04cd3ab to
68fd147
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
First batch of the "~11 blocking
modify_sessionsites" conversion, and the completionof what #62 started: the RAA now goes out on validation, but the apply it queues still
blocked the FSM on two PFCP round-trips.
Two sites, both inside the single
handle_event(internal, {gx_rar_apply, …})clause —the remove pass and the install pass. No caller ripple: one internal event, one emitter.
The remaining batches are filed with their call-graph analysis as #64 (
apply_bearer_change/5plus its four callers across three interfaces), #65 (six
pgw_s5s8bearer helpers, includingone inside an
ie_foldlthat needs a monadic fold) and #66 (ggsn_gnUpdate PDP).How blocking it was
Sharper than expected. With the old code the new test fails with
{timeout, {sys, get_state, [<0.2032.0>]}}— the context cannot answer a system message,because it is blocked inside
smf_sx_node:call/2for the whole PFCP retransmit window.What's here
gx_rar_apply_proc/3, a two-awaitasync_mprocedure: PFCP modify (remove) → the Gycharging round → PFCP modify (install) → allocation-failure CCR-U → write-back. The body
is the blocking code moved across; the two
case-wrappers aroundmodify_session/5aregone because failures now travel the error channel.
throw(Err#ctx_err{context = …, tunnel = …})from agen_statemcallback with no enclosingtry, so that path crashed the context withbad_return_from_state_functioninstead ofproducing an error reply.
gx_rar_apply_err/3now applies the same decoration and routesthrough
handle_ctx_error/4.{gx_rar_apply, …}gate clause stays — it is what stops a second procedure starting.A correction to #62's reasoning
#62's PR body argued that multiple in-flight RARs converge without extra state, because each
validates on top of the previous one's committed
PCC2and the applies run FIFO. That iswrong once the apply is async, and the existing
gx_rartest caught it: RAR #2 validates andcommits
PCC2#2while apply #1 is parked, then apply #1's write-back lands carryingPCC4#1derived from its own captured
PCC2#1and clobbers the removal.gx_rarfailed on?equal(false, maps:is_key(<<"r-0002">>, PCR2))in all three interfaces.The convergence argument only holds once all applies have run; it says nothing about the
window between validation #2 and apply #2. The fix is the
rar_apply_pendingflag I haddesigned for #62 and then dropped as unnecessary — one apply outstanding at a time, so a Gx RAR
arriving in that window is postponed. It lives in the gen_statem State, like
async_pending,so clearing it is a state-term change that re-delivers the postponed RARs.
This is deliberately much narrower than gating on
async_pending: a RAR arriving while anunrelated procedure is parked is still answered at once, which is what #62 bought and what
gx_rar_answers_raa_while_parkedcovers.Test-suite consequence
gx_rar_gy_interactionasserted PFCP timer counts immediately after each RAA, in all threesuites. That encoded the old synchronous coupling: the RAA now acknowledges validation, not
resource allocation (TS 29.212 §4.5.12), so PFCP-side state lands shortly after it. Those six
assertions became bounded waits. Related:
wait_until/3moved frompgw_SUITEintosmf_test_liband is imported viasmf_test_lib.hrl, since all three suites now need it.Worth noting the same assertions were already timing-sensitive after the change — saegw's copy
passed one run and failed the next — so the waits remove a real flake, not just a failure.
Testing
gx_rar_apply_is_asyncholds the UPF, injects a rule-installing Gx RAR and assertsasync_pending_sizereaches 1 — the apply parks rather than blocking. Verified red against thefinal test by reverting only the production files.
pgw_SUITE+ggsn_SUITE+saegw_s11_SUITE: 238 passed, 0 failures.Stacked on #63. Merge bottom-up: #45 → #46 → #48 → #56 → #57 → #58 → #59 → #61 → #62 → #63 → this.