@@ -53,8 +53,8 @@ use super::{
53
53
} ;
54
54
use crate :: { errors:: ConsumerError , metrics:: Metrics } ;
55
55
56
- const MAX_CONCURRENT_TASKS : usize = 30 ;
57
- const BATCH_SIZE : usize = 30 ;
56
+ const MAX_CONCURRENT_TASKS : usize = 32 ;
57
+ const BATCH_SIZE : usize = 100 ;
58
58
59
59
#[ derive( Debug ) ]
60
60
enum ProcessResult {
@@ -101,14 +101,14 @@ impl BlockExecutor {
101
101
102
102
while !token. is_cancelled ( ) {
103
103
let mut messages = queue. subscribe ( BATCH_SIZE ) . await ?;
104
+ let mut join_set = JoinSet :: new ( ) ;
104
105
while let Some ( msg) = messages. next ( ) . await {
105
- let mut join_set = JoinSet :: new ( ) ;
106
106
let msg = msg?;
107
107
self . spawn_processing_tasks ( msg, & mut join_set) . await ?;
108
- // Wait for all spawned tasks to complete before processing next message
109
- while let Some ( result ) = join_set . join_next ( ) . await {
110
- Self :: handle_task_result ( result, & telemetry ) . await ? ;
111
- }
108
+ }
109
+ // Wait for all spawned tasks to complete before processing next message
110
+ while let Some ( result) = join_set . join_next ( ) . await {
111
+ Self :: handle_task_result ( result , & telemetry ) . await ? ;
112
112
}
113
113
}
114
114
@@ -289,7 +289,18 @@ async fn handle_stores(
289
289
290
290
match result {
291
291
Ok ( packet_count) => Ok ( stats. finish ( packet_count) ) ,
292
- Err ( e) => Ok ( stats. finish_with_error ( e) ) ,
292
+ Err ( e) => {
293
+ if let ConsumerError :: Sqlx ( sqlx:: Error :: Database ( db_error) ) = & e {
294
+ if db_error. is_unique_violation ( ) {
295
+ tracing:: info!(
296
+ block_height = %msg_payload. block_height( ) ,
297
+ "Ignoring unique constraint violation - block already processed"
298
+ ) ;
299
+ return Ok ( stats. finish ( packets. len ( ) ) ) ;
300
+ }
301
+ }
302
+ Ok ( stats. finish_with_error ( e) )
303
+ }
293
304
}
294
305
}
295
306
0 commit comments