Track consecutive RPC timeouts in file distribution and close stale connections#36061
Merged
hmusum merged 1 commit intovespa-engine:masterfrom Mar 9, 2026
Merged
Conversation
…onnections When file distribution RPC requests time out repeatedly, the underlying TCP connection may be stale. This adds tracking of consecutive timeouts per connection in FileReferenceDownloader. When the count reaches a configurable threshold, the connection is closed via Target.close() so that JRTConnection.getTarget() will establish a fresh one on next use. The threshold is controlled by VESPA_FILE_DOWNLOAD_MAX_TIMEOUTS_BEFORE_CLOSE (default 0 = disabled), consistent with existing env var patterns. Changes: - Add closeConnection() default method to Connection interface - Implement closeConnection() in JRTConnection using target.close() - Add DownloadResult enum (SUCCESS/TIMEOUT/FAILURE) to FileReferenceDownloader - Track consecutive timeouts and close connection when threshold exceeded - Add FileDownloader constructor overload accepting maxTimeoutsBeforeClose - Add 3 tests: threshold=1, threshold=2, and disabled (threshold=0)
3 tasks
hmusum
approved these changes
Mar 9, 2026
Member
hmusum
left a comment
There was a problem hiding this comment.
This looks good, thanks for the contribution
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.
Summary
Target.close()soJRTConnection.getTarget()reconnects automaticallycloseConnection()to theConnectioninterface (default no-op) with implementation inJRTConnectionVESPA_FILE_DOWNLOAD_MAX_TIMEOUTS_BEFORE_CLOSEenv var (default0= disabled)Details
When a file distribution RPC request times out, the underlying TCP connection may be stale (e.g., broken by a load balancer or network partition). Previously, the downloader would keep retrying on the same dead connection until the overall download timeout expired.
Now,
FileReferenceDownloaderreturns aDownloadResultenum (SUCCESS/TIMEOUT/FAILURE) fromstartDownloadRpc. InwaitUntilDownloadStarted, consecutive timeouts are tracked per connection. When the count reachesmaxTimeoutsBeforeClose, the connection is closed and the counter resets. The connection pool'sswitchConnectionon each retry naturally picks up a fresh connection.Test plan
testConnectionCloseOnTimeout— threshold=1, verifies close called for each timeouttestConnectionCloseAfterNTimeouts— threshold=2 with 6 timeouts, verifies 3 closestestNoConnectionCloseOnTimeoutByDefault— threshold=0, verifies no closesFileDownloaderTesttests pass unchanged