Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcsrv: close idle client connections in doRPCCallOverHTTP #3350

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

roman-khimov
Copy link
Member

This doesn't fix anything, but why not (at least let's see how it behaves on GH).

Just FYI, I've also tried

--- a/pkg/services/rpcsrv/server_test.go
+++ b/pkg/services/rpcsrv/server_test.go
@@ -2223,7 +2223,16 @@ var rpcTestCases = map[string][]rpcTestCase{
 
 func TestRPC(t *testing.T) {
        t.Run("http", func(t *testing.T) {
-               testRPCProtocol(t, doRPCCallOverHTTP)
+               cl := http.Client{Timeout: time.Second}
+               testRPCProtocol(t, func(rpcCall string, url string, t *testing.T) []byte {
+                       resp, err := cl.Post(url, "application/json", strings.NewReader(rpcCall))
+                       require.NoErrorf(t, err, "could not make a POST request")
+                       body, err := gio.ReadAll(resp.Body)
+                       resp.Body.Close()
+                       assert.NoErrorf(t, err, "could not read response from the request: %s", rpcCall)
+                       return bytes.TrimSpace(body)
+               })
+               cl.CloseIdleConnections()
        })
 
        t.Run("websocket", func(t *testing.T) {

as optimization, but it doesn't affect test time in any way.

Shouldn't affect things much, yet at the same time we no longer need any
connection after we're done with the request.

Signed-off-by: Roman Khimov <[email protected]>
@roman-khimov roman-khimov added the rpc RPC server and client label Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.71%. Comparing base (54c53cf) to head (86faf7b).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3350   +/-   ##
=======================================
  Coverage   84.70%   84.71%           
=======================================
  Files         331      331           
  Lines       44932    44932           
=======================================
+ Hits        38060    38062    +2     
  Misses       5362     5362           
+ Partials     1510     1508    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AnnaShaleva AnnaShaleva added this to the v0.106.0 milestone Mar 14, 2024
@AnnaShaleva AnnaShaleva merged commit 67d3917 into master Mar 14, 2024
19 of 20 checks passed
@AnnaShaleva AnnaShaleva deleted the tune-rpc-tests branch March 14, 2024 07:52
@AnnaShaleva
Copy link
Member

BTW, the interesting fact is that we do the same with our real client:

// Close closes unused underlying networks connections.
func (c *Client) Close() {
c.ctxCancel()
c.cli.CloseIdleConnections()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rpc RPC server and client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants