Sessions that never call StreamEvents hold a worker for the full lease (1800 s); no lease renewal #167
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by a cross-repo review (OtOpcUa lmxopcua#735, GalaxyDriver respawn leak). Detach-grace only starts after a subscriber has attached at least once, so a session that never calls
StreamEventslives for the fullDefaultLeaseSeconds(1800 s).GatewaySession.ExtendLeasehas no callers and there is no renew RPC. A client that leaks sessions (each pinning an x86 worker) exhaustsMaxSessionsafter ~64 leaks inside the window.Ask: start the idle/detach grace at session open (or on last RPC activity), and/or add a lease-renew RPC that clients call on keep-alive.
Fixed on origin/main and verified (closing as part of #169).
285ef64addsMxGateway:Sessions:UnattachedSessionGraceSeconds. When it's set, the lease sweep reaps a Ready session that has never had a subscriber (external or internal) once it has been idle for the window. The window runs from the later of Ready and the last unary command.ec9f264is a follow-up that exempts internal subscribers and handles close races. Both are in merge7f0720f.SessionManagerTests:CloseExpiredLeasesAsync_ReapsNeverSubscribedSessionAfterUnattachedGrace,_UnattachedGrace_IsRestartedByUnaryActivity,_DoesNotReapSessionThatSubscribed,_DoesNotReapSessionWithInternalSubscriber,_IdleClockStartsAtReady,_IsDisabledByDefault.--filter CloseExpiredLeasesAsyncgives 19/19 on macOS; the full gateway suite is 1349/1349 on windev at777fef9.Operational note: the setting defaults to
0, which is off. A deployment only gets the protection against leaked sessions if it setsUnattachedSessionGraceSecondsabove its clients' OpenSession→StreamEvents time (seedocs/GatewayConfiguration.md). There is still no lease-renew RPC; this fix implements the "idle grace from last RPC activity" option the issue asked for.