atelet: close ateom conns evicted from the dialer cache - #1010
Open
Da Huang (git286) wants to merge 1 commit into
Open
atelet: close ateom conns evicted from the dialer cache#1010Da Huang (git286) wants to merge 1 commit into
Da Huang (git286) wants to merge 1 commit into
Conversation
AteomDialer caches one grpc.ClientConn per worker pod UID in a 256-entry LRU, but the cache had no eviction function: a conn pushed out to make room was forgotten, never closed. grpc does not reclaim an un-Closed conn -- measured against a dead socket, each one holds 4 goroutines, and the channel idle timeout later parks only one of them, so ~3 goroutines and their buffers leak per eviction for the life of the process. Today evictions need >256 distinct worker pods dialed since atelet started, so the leak is a slow drip reset by restarts. The stats poller proposed in agent-substrate#961 would sweep every ateoms/ directory (including the stale ones nothing garbage-collects) through this cache every minute, turning the drip into hundreds of leaked conns per tick on long-lived nodes. Close evicted conns via the cache's eviction hook. The trade is that an RPC still in flight on a conn that aged to the LRU tail now fails visibly instead of completing on a leaked conn; that needs the same >256-pod churn, and the failure is retryable. Fixes agent-substrate#1009.
Da Huang (git286)
requested review from
Benjamin Elder (BenTheElder) and
Julian Gutierrez Oschmann (juli4n)
August 17, 2026 19:33
| func newAteomDialer(size int) *AteomDialer { | ||
| return &AteomDialer{ | ||
| conns: lru.NewWithEvictionFunc(size, func(_ lru.Key, value interface{}) { | ||
| value.(*grpc.ClientConn).Close() |
Collaborator
There was a problem hiding this comment.
A made the same comment in #480 : If we blindly close on eviction, can this close a connection which is already in use?
Collaborator
Author
There was a problem hiding this comment.
Get moves an entry to the front. Every RPC starts with DialAteomPod → Get, so a conn with an RPC in flight was most-recently-used the moment the RPC began. For it to reach the eviction end of the queue mid-RPC, atelet would have to dial 256 other distinct pod UIDs in the window between that RPC starting and finishing, which is extremely unlikely, right?
Collaborator
|
IIRC ate-apiserver has the same issue as it also caches connections (to atelet). |
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.
AteomDialer caches one grpc.ClientConn per worker pod UID in a 256-entry LRU, but the cache had no eviction function: a conn pushed out to make room was forgotten, never closed. grpc does not reclaim an un-Closed conn -- measured against a dead socket, each one holds 4 goroutines, and the channel idle timeout later parks only one of them, so ~3 goroutines and their buffers leak per eviction for the life of the process.
Today evictions need >256 distinct worker pods dialed since atelet started, so the leak is a slow drip reset by restarts. Close evicted conns via the cache's eviction hook. The trade is that an RPC still in flight on a conn that aged to the LRU tail now fails visibly instead of completing on a leaked conn; that needs the same >256-pod churn, and the failure is retryable.
Fixes #1009.