@@ -88,13 +88,17 @@ impl StartedConnectorState {
88
88
}
89
89
}
90
90
91
+ const MAX_PARSE_ERRORS_IN_LOG : usize = 128 ;
92
+
91
93
pub struct Connector {
92
94
commit_duration : Option < Duration > ,
93
95
current_timestamp : Timestamp ,
94
96
num_columns : usize ,
95
97
current_frontier : OffsetAntichain ,
96
98
skip_all_errors : bool ,
97
99
error_logger : Rc < dyn LogError > ,
100
+ n_parse_attempts : usize ,
101
+ n_parse_errors_in_log : usize ,
98
102
}
99
103
100
104
#[ derive( Debug ) ]
@@ -201,6 +205,8 @@ impl Connector {
201
205
current_frontier : OffsetAntichain :: new ( ) ,
202
206
skip_all_errors,
203
207
error_logger,
208
+ n_parse_attempts : 0 ,
209
+ n_parse_errors_in_log : 0 ,
204
210
}
205
211
}
206
212
@@ -624,7 +630,10 @@ impl Connector {
624
630
}
625
631
ReadResult :: Data ( reader_context, offset) => {
626
632
let mut parsed_entries = match parser. parse ( & reader_context) {
627
- Ok ( entries) => entries,
633
+ Ok ( entries) => {
634
+ self . log_parse_success ( ) ;
635
+ entries
636
+ }
628
637
Err ( e) => {
629
638
self . log_parse_error ( e) ;
630
639
return ;
@@ -815,13 +824,25 @@ impl Connector {
815
824
}
816
825
}
817
826
818
- fn log_parse_error ( & self , error : DynError ) {
827
+ fn log_parse_error ( & mut self , error : DynError ) {
828
+ self . n_parse_attempts += 1 ;
819
829
if self . skip_all_errors {
820
- error ! ( "Parse error: {error}" ) ;
830
+ self . n_parse_errors_in_log += 1 ;
831
+ let needs_error_log = self . n_parse_errors_in_log <= MAX_PARSE_ERRORS_IN_LOG
832
+ || self . n_parse_errors_in_log * 10 <= self . n_parse_attempts ;
833
+ if needs_error_log {
834
+ error ! ( "Parse error: {error}" ) ;
835
+ } else if self . n_parse_errors_in_log == MAX_PARSE_ERRORS_IN_LOG + 1 {
836
+ error ! ( "Too many parse errors, some of them will be omitted..." ) ;
837
+ }
821
838
} else {
822
839
self . error_logger . log_error ( error. into ( ) ) ;
823
840
}
824
841
}
842
+
843
+ fn log_parse_success ( & mut self ) {
844
+ self . n_parse_attempts += 1 ;
845
+ }
825
846
}
826
847
827
848
pub struct SnapshotReaderState {
0 commit comments