Skip to content

Fix aggregation metadata session not reconnecting after downstream loss (#312) - #750

Merged
romanett merged 1 commit into
masterfrom
romanett-fluffy-journey
Aug 13, 2026
Merged

Fix aggregation metadata session not reconnecting after downstream loss (#312)#750
romanett merged 1 commit into
masterfrom
romanett-fluffy-journey

Conversation

@romanett

Copy link
Copy Markdown
Contributor

Proposed changes

The aggregation server's internal "metadata" session never recovered after a downstream server was restarted or the network connection was lost (issue #312). Once the keep-alive went "late", the aggregator kept retrying but never re-established the session.

The root cause is in Client_KeepAlive (Workshop/Aggregation/Server/AggregationNodeManager.cs). Reconnection was gated on session.OutstandingRequestCount + session.DefunctRequestCount >= 3. When the downstream drops, the keep-alive read fails synchronously (e.g. BadConnectionClosed) before the request is ever registered, so those counters never increment and the gate never opened. The SessionReconnectHandler was therefore never started.

This change starts reconnection immediately on any not-good keep-alive status (ServiceResult.IsNotGood(e.Status)), keeping only the !session.SessionId.IsNull guard. The existing stale-session cleanup in GetClientSession remains as a backstop.

Note: the original report also described a stack-level secure-channel "renew instead of recreate" failure (BadTcpSecureChannelUnknown) against stack 1.4.368. This sample now runs on stack 2.0.158-preview, where that behavior has been reworked, so no samples change is needed for that half.

Related Issues

Types of changes

What types of changes does your code introduce?

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

The removed count-based gate was the specific mechanism the issue reporter identified as never firing. Reconnecting on a bad keep-alive status matches the pattern used by the reference client samples. The Aggregation Server project builds cleanly with this change (remaining warnings are pre-existing and unrelated).

@romanett
romanett merged commit 303e76a into master Aug 13, 2026
1 of 4 checks passed
…ss (#312)

Reconnect the aggregation server's downstream session on any not-good keep-alive status instead of gating on OutstandingRequestCount + DefunctRequestCount >= 3. When the downstream server restarts or the network drops, the keep-alive read fails synchronously (BadConnectionClosed) before the request is registered, so those counters never rise and the reconnect logic never fired.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanett
romanett deleted the romanett-fluffy-journey branch August 14, 2026 05:14
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.

Aggregation server does not reconnect to downstream servers when server is restarted or network connection is lost

1 participant