File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ pub enum IngesterError {
16
16
InvalidEvent ,
17
17
#[ error( "Custom error: {0}" ) ]
18
18
CustomError ( String ) ,
19
+ #[ error( "Gap detected, triggering rewind" ) ]
20
+ GapDetectedRewind ,
19
21
}
20
22
21
23
impl From < sea_orm:: error:: DbErr > for IngesterError {
Original file line number Diff line number Diff line change @@ -72,11 +72,13 @@ pub fn get_block_poller_stream(
72
72
log:: error!( "Rewinding block stream to {}: {}" , to_slot, reason) ;
73
73
// Clear cached blocks
74
74
block_cache. clear( ) ;
75
+ // Clear sequence state to re-learn from rewound point
76
+ crate :: ingester:: gap:: clear_sequence_state( ) ;
75
77
// Reset positions
76
78
last_indexed_slot = to_slot - 1 ;
77
79
current_start_slot = to_slot;
78
80
rewind_occurred = true ;
79
- log:: info!( "Cleared cache, restarting from slot {}" , current_start_slot) ;
81
+ log:: info!( "Cleared cache and sequence state , restarting from slot {}" , current_start_slot) ;
80
82
break ;
81
83
}
82
84
}
Original file line number Diff line number Diff line change @@ -112,9 +112,11 @@ pub async fn index_block_stream(
112
112
}
113
113
}
114
114
Err ( e) => {
115
- if e . to_string ( ) . contains ( "Gap detection triggered rewind" ) {
115
+ if matches ! ( e , crate :: ingester :: error :: IngesterError :: GapDetectedRewind ) {
116
116
// Gap detected, rewind triggered - the slot stream should handle repositioning
117
117
log:: info!( "Gap detection triggered rewind" ) ;
118
+ // Clear sequence state to re-learn from the rewound point
119
+ crate :: ingester:: gap:: clear_sequence_state ( ) ;
118
120
continue ;
119
121
} else {
120
122
log:: error!( "Unexpected error in block processing: {}" , e) ;
Original file line number Diff line number Diff line change @@ -72,9 +72,7 @@ fn derive_block_state_update(
72
72
) ) ;
73
73
}
74
74
// Return early after requesting rewind - don't continue processing
75
- return Err ( IngesterError :: CustomError (
76
- "Gap detection triggered rewind" . to_string ( ) ,
77
- ) ) ;
75
+ return Err ( IngesterError :: GapDetectedRewind ) ;
78
76
}
79
77
}
80
78
@@ -203,7 +201,7 @@ pub async fn index_block_batch_with_infinite_retries(
203
201
Ok ( ( ) ) => return Ok ( ( ) ) ,
204
202
Err ( e) => {
205
203
// Check if this is a gap-triggered rewind error
206
- if e . to_string ( ) . contains ( "Gap detection triggered rewind" ) {
204
+ if matches ! ( e , IngesterError :: GapDetectedRewind ) {
207
205
// Don't retry, propagate the rewind error up
208
206
return Err ( e) ;
209
207
}
You can’t perform that action at this time.
0 commit comments