fix(galaxy): #865 review round 1 - stale-session pump, data-path stream wait
- EnsureEventPumpStarted replaces a pump created for an older registry session (the reopen -> replay window still held the dead session's pump, so an advise there lost its initial value and the replay skipped it); RestartEventPumpForReplay keeps a pump already on the current session. - SubscribeAsync, read-via-subscribe and ReplayAsync also await the bounded StreamRequested wait before advising, not just the probes. - TryEnsureEventPumpStarted tolerates a teardown flipping _runtimeStopping mid-check; the probe hook honours an already-cancelled seed token. - StreamRequested is documented as narrowing, not closing, the attach race. - Tests: reopen-window probe test, EventPump.StreamRequested tests, and the FixRound1 fresh-pump assertion now waits on a positive control. Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
@@ -148,15 +148,27 @@ internal sealed class EventPump : IAsyncDisposable
|
||||
|
||||
private readonly int _session;
|
||||
|
||||
/// <summary>
|
||||
/// The registry session this pump was created for (#865). A pump of an older session was opened
|
||||
/// against a gateway session a reconnect replaced; its stream will never carry the new session's events.
|
||||
/// </summary>
|
||||
internal int Session => _session;
|
||||
|
||||
private readonly TaskCompletionSource _streamRequested = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
/// <summary>
|
||||
/// Completes once the stream loop has issued its <c>StreamEvents</c> call (the first
|
||||
/// <c>MoveNextAsync</c> runs the subscriber's iterator synchronously up to the RPC) — or once the
|
||||
/// loop has ended without getting that far, so a waiter never hangs on a dead pump. #865: the
|
||||
/// gateway does not replay a fresh stream, so a caller whose only expected event is the initial
|
||||
/// value of an advise it is about to make waits on this first.
|
||||
/// Completes once the stream loop has STARTED its <c>StreamEvents</c> call (the first
|
||||
/// <c>MoveNextAsync</c> runs the subscriber's iterator synchronously up to the gRPC call creation) —
|
||||
/// or once the loop has ended without getting that far, so a waiter never hangs on a dead pump.
|
||||
/// #865: the gateway does not replay a fresh stream, so a caller whose only expected event is the
|
||||
/// initial value of an advise it is about to make waits on this first.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ⚠️ This NARROWS the stream-attach race, it does not close it: the HTTP/2 request is sent
|
||||
/// asynchronously and the gateway attaches the subscriber after auth, concurrently with any other
|
||||
/// RPC. In practice the attach wins (an advise's initial value needs a worker IPC round trip plus an
|
||||
/// MXAccess advise), but the gateway offers no attach acknowledgement to await.
|
||||
/// </remarks>
|
||||
public Task StreamRequested => _streamRequested.Task;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user