Skip to content

Commit 9165d8e

Browse files
riptlmmcgee-jump
authored andcommitted
bundle: abandon conn if bundle stream ends
If a backend ends the bundle gRPC stream, that's typically an indication that this backend is done serving requests. Need to re-resolve DNS and reconnect in order to reach the new backend server.
1 parent 28ae02f commit 9165d8e

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/disco/bundle/fd_bundle_client.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,18 @@ fd_bundle_client_grpc_rx_end(
848848
ctx->packet_subscription_live = 0;
849849
ctx->packet_subscription_wait = 0;
850850
fd_bundle_tile_backoff( ctx, fd_tickcount() );
851-
break;
851+
ctx->defer_reset = 1;
852+
FD_LOG_INFO(( "SubscribePackets stream failed (gRPC status %u-%s). Reconnecting ...",
853+
resp->grpc_status, fd_grpc_status_cstr( resp->grpc_status ) ));
854+
return;
852855
case FD_BUNDLE_CLIENT_REQ_Bundle_SubscribeBundles:
853856
ctx->bundle_subscription_live = 0;
854857
ctx->bundle_subscription_wait = 0;
855858
fd_bundle_tile_backoff( ctx, fd_tickcount() );
856-
break;
859+
ctx->defer_reset = 1;
860+
FD_LOG_INFO(( "SubscribeBundles stream failed (gRPC status %u-%s). Reconnecting ...",
861+
resp->grpc_status, fd_grpc_status_cstr( resp->grpc_status ) ));
862+
return;
857863
default:
858864
break;
859865
}

src/disco/bundle/test_bundle_client.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ test_missing_builder_fee_info( fd_wksp_t * wksp ) {
177177
test_bundle_env_destroy( env );
178178
}
179179

180-
/* Ensure that the client re-requests a stream if the server ends it */
180+
/* Ensure that the client reconnects (with a new TCP socket) if the
181+
server ends the stream */
181182

182183
static void
183184
test_stream_ended( fd_wksp_t * wksp ) {
@@ -192,19 +193,9 @@ test_stream_ended( fd_wksp_t * wksp ) {
192193
.h2_status = 200,
193194
.grpc_status = FD_GRPC_STATUS_OK
194195
};
196+
FD_TEST( state->defer_reset==0 );
195197
fd_bundle_client_grpc_rx_end( state, FD_BUNDLE_CLIENT_REQ_Bundle_SubscribeBundles, &hdrs );
196-
197-
/* Ensure that client doesn't immediately transmit */
198-
long clock = fd_tickcount();
199-
FD_TEST( fd_bundle_tile_should_stall( state, clock ) );
200-
FD_TEST( !fd_bundle_tile_should_stall( state, state->backoff_until + 1L ) );
201-
202-
/* Client should send a SubscribeBundles request */
203-
FD_TEST( fd_bundle_client_step_reconnect( state, clock )==1 );
204-
FD_TEST( rbuf_tx->hi_off>=sizeof(fd_h2_frame_hdr_t) );
205-
fd_h2_frame_hdr_t headers_hdr;
206-
fd_h2_rbuf_pop_copy( rbuf_tx, &headers_hdr, sizeof(fd_h2_frame_hdr_t) );
207-
FD_TEST( fd_h2_frame_type( headers_hdr.typlen )==FD_H2_FRAME_TYPE_HEADERS );
198+
FD_TEST( state->defer_reset==1 );
208199
}
209200

210201
#if FD_HAS_INT128

0 commit comments

Comments
 (0)