Skip to content

stop waiting for the Gx terminate answer - #63

Merged
next-nf merged 1 commit into
mainfrom
async-terminate-step4
Jul 27, 2026
Merged

stop waiting for the Gx terminate answer#63
next-nf merged 1 commit into
mainfrom
async-terminate-step4

Conversation

@next-nf

@next-nf next-nf commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Completes rollout step 4 — "Terminate. Convert the deliberately-sync Gx terminate."

smf_gtp_gsn_session:close_context/7 builds ReqOpts = #{now => Now, async => true} and
then overrides it for the Gx terminate alone with ReqOpts#{async => false}. The Gy
terminate further down the same function already uses ReqOpts unmodified. This drops the
override, making Gx consistent with the Gy call beside it.

Why it is safe

smf_aaa_gx:invoke/6's CCR-Terminate clause is
await_response(send_request(Request, Opts), Session, Events, State, Opts) — and the
ordering is what matters. smf_aaa_diameter_srv:send_request/4 mints the Promise and
spawns the process that performs the diameter:call before returning, and that process
is not linked to the context. So the CCR-T is already on its way by the time the handler
decides whether to wait, and it completes even if the context dies. async => true changes
only whether we block for the CCA-T, never whether the CCR-T is sent. The
#state{state = stopped} transition and inc_request_number/1 also happen pre-send in the
same clause.

Why it is worth doing

The wait was unbounded: smf_aaa_diameter_srv:await_response/1 is
await_response(Promise, infinity). A PCRF that never answered the CCR-T hung the context in
teardown permanently, unable to service anything — including the reentrant traffic this whole
initiative exists to keep flowing. The architecture doc flags exactly this: "the current
diameter sync receives use infinity — that becomes a design requirement, not an option."

This is not a considered decision being reversed. git log -S "async => false" dates the
override to the 2020 "unify large parts of the GTP handlers" refactor, inherited from the
original erGW code.

What is lost

The two branches only logged. The {ok, …} branch also threaded the post-CCA PCF/Session
onward, but smf_gtp_gsn_lib:close_context/4 discards them moments later while finishing the
teardown. So the real loss is the warning telling an operator the PCRF rejected the terminate
— accepted, since the session is going away and there is no action the PCEF takes on a failed
CCR-T. A ?LOG(debug, "Gx terminate issued") replaces the pair, and the case is kept so a
non-ok return still falls back to the pre-call values.

Testing — stated plainly

pgw_SUITE cannot discriminate this change, and I did not add a test pretending
otherwise. Its AAA handler is the synchronous smf_aaa_static mock, which never reaches
smf_aaa_gx:invoke/6, so the async flag is inert there — the same infrastructure gap
recorded in #60. Any test I wrote would pass identically before and after.

What the existing suites do cover, and keeps passing: pgw_SUITE asserts
meck:called(smf_aaa_pcf, ccr_terminate, ['_','_','_','_']), the Final-Gx answer is wired
for {gx, 'CCR-Terminate'} so every teardown in the suite runs this path, and ggsn_SUITE
and saegw_s11_SUITE tear down through the same shared close_context/7.

pgw_SUITE + ggsn_SUITE + saegw_s11_SUITE: 237 passed, 0 failures.

Still blocking in teardown, out of scope: smf_gtp_gsn_lib:close_context/3 calls
smf_pfcp_context:delete_session/2 synchronously. Converting it needs the context to stay
alive awaiting the reply, which conflicts with the teardown clauses that transition straight
to shutdown — it belongs with the "~11 blocking modify_session sites" work.

With this, all five rollout steps are done. Stacked on #62; merge bottom-up:
#45#46#48#56#57#58#59#61#62 → this.

@next-nf
next-nf force-pushed the async-gate-rar-raa branch from 1174ee7 to d8bd9b6 Compare July 27, 2026 11:44
@next-nf
next-nf force-pushed the async-terminate-step4 branch from 7a44782 to 723e0b4 Compare July 27, 2026 11:44
@next-nf
next-nf force-pushed the async-gate-rar-raa branch from d8bd9b6 to ff6e8ff Compare July 27, 2026 12:16
@next-nf
next-nf force-pushed the async-terminate-step4 branch from 723e0b4 to 44d125a Compare July 27, 2026 12:16
@next-nf
next-nf force-pushed the async-gate-rar-raa branch from ff6e8ff to 793815b Compare July 27, 2026 12:23
@next-nf
next-nf force-pushed the async-terminate-step4 branch from 44d125a to a826616 Compare July 27, 2026 12:23
Base automatically changed from async-gate-rar-raa to main July 27, 2026 12:29
@next-nf
next-nf merged commit 2861bb7 into main Jul 27, 2026
@next-nf
next-nf deleted the async-terminate-step4 branch July 27, 2026 12:29
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.

1 participant