@@ -72,7 +72,8 @@ impl ServerState {
7272 config : & ' static Config ,
7373 ) -> Self {
7474 let dispatcher = Dispatcher :: new ( reservation_expiration) ;
75- let ( completer, completer_tx) = Completer :: new ( pool. writer_pool ( ) , & dispatcher) ;
75+ let ( completer, completer_tx) =
76+ Completer :: new ( pool. writer_pool ( ) , & dispatcher, config. max_chunk_retries ) ;
7677 Self {
7778 pool,
7879 completer : Some ( completer) ,
@@ -170,12 +171,14 @@ pub struct Completer {
170171 pool : db:: WriterPool ,
171172 dispatcher : Dispatcher ,
172173 count : usize ,
174+ max_chunk_retries : u32 ,
173175}
174176
175177impl Completer {
176178 pub fn new (
177179 pool : & db:: WriterPool ,
178180 dispatcher : & Dispatcher ,
181+ max_chunk_retries : u32 ,
179182 ) -> ( Self , tokio:: sync:: mpsc:: Sender < CompleterMessage > ) {
180183 let ( tx, rx) = tokio:: sync:: mpsc:: channel ( 1024 ) ;
181184 let pool = pool. clone ( ) ;
@@ -184,6 +187,7 @@ impl Completer {
184187 pool : pool. clone ( ) ,
185188 dispatcher : dispatcher. clone ( ) ,
186189 count : 0 ,
190+ max_chunk_retries,
187191 } ;
188192 ( me, tx)
189193 }
@@ -243,8 +247,13 @@ impl Completer {
243247 } => {
244248 // Even in the unlikely event that the DB write fails,
245249 // we still want to unreserve the chunk
246- let failed_permanently =
247- crate :: common:: chunk:: db:: retry_or_fail_chunk ( id, failure, & mut conn) . await ;
250+ let failed_permanently = crate :: common:: chunk:: db:: retry_or_fail_chunk (
251+ id,
252+ failure,
253+ & mut conn,
254+ self . max_chunk_retries ,
255+ )
256+ . await ;
248257 reservations. lock ( ) . expect ( "No poison" ) . remove ( & id) ;
249258 let maybe_started_at = self
250259 . dispatcher
0 commit comments