@@ -67,18 +67,18 @@ impl GrpcClient {
67
67
68
68
/// Returns whether this gRPC status means the server stream should be reconnected to, or not.
69
69
/// Logs a warning on unexpected status codes.
70
- fn is_retryable ( status : & Status ) -> bool {
70
+ fn is_retryable ( status : & Status , address : & str ) -> bool {
71
71
match status. code ( ) {
72
72
Code :: DeadlineExceeded | Code :: Aborted | Code :: Unavailable | Code :: Unknown => {
73
- info ! ( "gRPC request interrupted: {}; retrying" , status ) ;
73
+ info ! ( "gRPC request to {address} interrupted: {status }; retrying" ) ;
74
74
true
75
75
}
76
76
Code :: Ok
77
77
| Code :: Cancelled
78
78
| Code :: NotFound
79
79
| Code :: AlreadyExists
80
80
| Code :: ResourceExhausted => {
81
- error ! ( "Unexpected gRPC status : {}; retrying" , status ) ;
81
+ error ! ( "gRPC request to {address} interrupted : {status }; retrying" ) ;
82
82
true
83
83
}
84
84
Code :: InvalidArgument
@@ -89,7 +89,7 @@ impl GrpcClient {
89
89
| Code :: Internal
90
90
| Code :: DataLoss
91
91
| Code :: Unauthenticated => {
92
- error ! ( "Unexpected gRPC status: {}" , status) ;
92
+ error ! ( "Unexpected gRPC status received from {address}: { status}" ) ;
93
93
false
94
94
}
95
95
}
@@ -100,6 +100,7 @@ impl GrpcClient {
100
100
f : F ,
101
101
request : impl TryInto < R > + fmt:: Debug + Clone ,
102
102
handler : & str ,
103
+ address : & str ,
103
104
) -> Result < S , NodeError >
104
105
where
105
106
F : Fn ( ValidatorNodeClient < transport:: Channel > , Request < R > ) -> Fut ,
@@ -113,15 +114,17 @@ impl GrpcClient {
113
114
} ) ?;
114
115
loop {
115
116
match f ( self . client . clone ( ) , Request :: new ( request_inner. clone ( ) ) ) . await {
116
- Err ( s) if Self :: is_retryable ( & s) && retry_count < self . max_retries => {
117
+ Err ( s) if Self :: is_retryable ( & s, address ) && retry_count < self . max_retries => {
117
118
let delay = self . retry_delay . saturating_mul ( retry_count) ;
118
119
retry_count += 1 ;
119
120
linera_base:: time:: timer:: sleep ( delay) . await ;
120
121
continue ;
121
122
}
122
123
Err ( s) => {
123
124
return Err ( NodeError :: GrpcError {
124
- error : format ! ( "remote request [{handler}] failed with status: {s:?}" , ) ,
125
+ error : format ! (
126
+ "remote request [{handler}] to {address} failed with status: {s:?}" ,
127
+ ) ,
125
128
} ) ;
126
129
}
127
130
Ok ( result) => return Ok ( result. into_inner ( ) ) ,
@@ -160,6 +163,7 @@ macro_rules! client_delegate {
160
163
|mut client, req| async move { client. $handler( req) . await } ,
161
164
$req,
162
165
stringify!( $handler) ,
166
+ & $self. address,
163
167
)
164
168
. await
165
169
} } ;
@@ -257,6 +261,7 @@ impl ValidatorNode for GrpcClient {
257
261
258
262
// The stream of `Notification`s that inserts increasing delays after retriable errors, and
259
263
// terminates after unexpected or fatal errors.
264
+ let address = self . address . clone ( ) ;
260
265
let notification_stream = endlessly_retrying_notification_stream
261
266
. map ( |result| {
262
267
Option :: < Notification > :: try_from ( result?) . map_err ( |err| {
@@ -269,7 +274,7 @@ impl ValidatorNode for GrpcClient {
269
274
retry_count = 0 ;
270
275
return future:: Either :: Left ( future:: ready ( true ) ) ;
271
276
} ;
272
- if !Self :: is_retryable ( status) || retry_count >= max_retries {
277
+ if !Self :: is_retryable ( status, & address ) || retry_count >= max_retries {
273
278
return future:: Either :: Left ( future:: ready ( false ) ) ;
274
279
}
275
280
let delay = retry_delay. saturating_mul ( retry_count) ;
0 commit comments