@@ -7,8 +7,13 @@ use crate::configs::store::Store;
7
7
const DEFAULT_BATCH_MAX_SIZE : usize = 100000 ;
8
8
const DEFAULT_BATCH_MAX_FILL_MS : u64 = 10000 ;
9
9
const DEFAULT_TABLE_ERROR_RETRY_DELAY_MS : u64 = 10000 ;
10
+ const DEFAULT_TABLE_ERROR_RETRY_MAX_ATTEMPTS : u32 = 5 ;
10
11
const DEFAULT_MAX_TABLE_SYNC_WORKERS : u16 = 4 ;
11
12
13
+ const fn default_table_error_retry_max_attempts ( ) -> u32 {
14
+ DEFAULT_TABLE_ERROR_RETRY_MAX_ATTEMPTS
15
+ }
16
+
12
17
/// Batch processing configuration for pipelines.
13
18
#[ derive( Clone , Debug , Serialize , Deserialize , ToSchema ) ]
14
19
#[ serde( rename_all = "snake_case" ) ]
@@ -30,6 +35,9 @@ pub struct FullApiPipelineConfig {
30
35
#[ schema( example = 1000 ) ]
31
36
#[ serde( skip_serializing_if = "Option::is_none" ) ]
32
37
pub table_error_retry_delay_ms : Option < u64 > ,
38
+ #[ schema( example = 5 ) ]
39
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
40
+ pub table_error_retry_max_attempts : Option < u32 > ,
33
41
#[ schema( example = 4 ) ]
34
42
#[ serde( skip_serializing_if = "Option::is_none" ) ]
35
43
pub max_table_sync_workers : Option < u16 > ,
@@ -44,6 +52,7 @@ impl From<StoredPipelineConfig> for FullApiPipelineConfig {
44
52
max_fill_ms : Some ( value. batch . max_fill_ms ) ,
45
53
} ) ,
46
54
table_error_retry_delay_ms : Some ( value. table_error_retry_delay_ms ) ,
55
+ table_error_retry_max_attempts : Some ( value. table_error_retry_max_attempts ) ,
47
56
max_table_sync_workers : Some ( value. max_table_sync_workers ) ,
48
57
}
49
58
}
@@ -60,6 +69,9 @@ pub struct PartialApiPipelineConfig {
60
69
#[ schema( example = 1000 ) ]
61
70
#[ serde( skip_serializing_if = "Option::is_none" ) ]
62
71
pub table_error_retry_delay_ms : Option < u64 > ,
72
+ #[ schema( example = 5 ) ]
73
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
74
+ pub table_error_retry_max_attempts : Option < u32 > ,
63
75
#[ schema( example = 4 ) ]
64
76
#[ serde( skip_serializing_if = "Option::is_none" ) ]
65
77
pub max_table_sync_workers : Option < u16 > ,
@@ -70,6 +82,8 @@ pub struct StoredPipelineConfig {
70
82
pub publication_name : String ,
71
83
pub batch : BatchConfig ,
72
84
pub table_error_retry_delay_ms : u64 ,
85
+ #[ serde( default = "default_table_error_retry_max_attempts" ) ]
86
+ pub table_error_retry_max_attempts : u32 ,
73
87
pub max_table_sync_workers : u16 ,
74
88
}
75
89
@@ -85,6 +99,7 @@ impl StoredPipelineConfig {
85
99
pg_connection : pg_connection_config,
86
100
batch : self . batch ,
87
101
table_error_retry_delay_ms : self . table_error_retry_delay_ms ,
102
+ table_error_retry_max_attempts : self . table_error_retry_max_attempts ,
88
103
max_table_sync_workers : self . max_table_sync_workers ,
89
104
}
90
105
}
@@ -107,6 +122,10 @@ impl StoredPipelineConfig {
107
122
self . table_error_retry_delay_ms = value;
108
123
}
109
124
125
+ if let Some ( value) = partial. table_error_retry_max_attempts {
126
+ self . table_error_retry_max_attempts = value;
127
+ }
128
+
110
129
if let Some ( value) = partial. max_table_sync_workers {
111
130
self . max_table_sync_workers = value;
112
131
}
@@ -134,6 +153,9 @@ impl From<FullApiPipelineConfig> for StoredPipelineConfig {
134
153
table_error_retry_delay_ms : value
135
154
. table_error_retry_delay_ms
136
155
. unwrap_or ( DEFAULT_TABLE_ERROR_RETRY_DELAY_MS ) ,
156
+ table_error_retry_max_attempts : value
157
+ . table_error_retry_max_attempts
158
+ . unwrap_or ( DEFAULT_TABLE_ERROR_RETRY_MAX_ATTEMPTS ) ,
137
159
max_table_sync_workers : value
138
160
. max_table_sync_workers
139
161
. unwrap_or ( DEFAULT_MAX_TABLE_SYNC_WORKERS ) ,
@@ -155,6 +177,7 @@ mod tests {
155
177
max_fill_ms : 5000 ,
156
178
} ,
157
179
table_error_retry_delay_ms : 2000 ,
180
+ table_error_retry_max_attempts : 7 ,
158
181
max_table_sync_workers : 4 ,
159
182
} ;
160
183
@@ -167,6 +190,10 @@ mod tests {
167
190
config. table_error_retry_delay_ms,
168
191
deserialized. table_error_retry_delay_ms
169
192
) ;
193
+ assert_eq ! (
194
+ config. table_error_retry_max_attempts,
195
+ deserialized. table_error_retry_max_attempts
196
+ ) ;
170
197
assert_eq ! (
171
198
config. max_table_sync_workers,
172
199
deserialized. max_table_sync_workers
@@ -179,6 +206,7 @@ mod tests {
179
206
publication_name : "test_publication" . to_string ( ) ,
180
207
batch : None ,
181
208
table_error_retry_delay_ms : None ,
209
+ table_error_retry_max_attempts : None ,
182
210
max_table_sync_workers : None ,
183
211
} ;
184
212
@@ -194,6 +222,7 @@ mod tests {
194
222
publication_name : "test_publication" . to_string ( ) ,
195
223
batch : None ,
196
224
table_error_retry_delay_ms : None ,
225
+ table_error_retry_max_attempts : None ,
197
226
max_table_sync_workers : None ,
198
227
} ;
199
228
@@ -205,6 +234,10 @@ mod tests {
205
234
stored. table_error_retry_delay_ms,
206
235
DEFAULT_TABLE_ERROR_RETRY_DELAY_MS
207
236
) ;
237
+ assert_eq ! (
238
+ stored. table_error_retry_max_attempts,
239
+ DEFAULT_TABLE_ERROR_RETRY_MAX_ATTEMPTS
240
+ ) ;
208
241
assert_eq ! (
209
242
stored. max_table_sync_workers,
210
243
DEFAULT_MAX_TABLE_SYNC_WORKERS
@@ -220,6 +253,7 @@ mod tests {
220
253
max_fill_ms : 2000 ,
221
254
} ,
222
255
table_error_retry_delay_ms : 1000 ,
256
+ table_error_retry_max_attempts : 3 ,
223
257
max_table_sync_workers : 2 ,
224
258
} ;
225
259
@@ -230,6 +264,7 @@ mod tests {
230
264
max_fill_ms : Some ( 8000 ) ,
231
265
} ) ,
232
266
table_error_retry_delay_ms : Some ( 5000 ) ,
267
+ table_error_retry_max_attempts : Some ( 9 ) ,
233
268
max_table_sync_workers : None ,
234
269
} ;
235
270
@@ -239,6 +274,7 @@ mod tests {
239
274
assert_eq ! ( stored. batch. max_size, 1000 ) ;
240
275
assert_eq ! ( stored. batch. max_fill_ms, 8000 ) ;
241
276
assert_eq ! ( stored. table_error_retry_delay_ms, 5000 ) ;
277
+ assert_eq ! ( stored. table_error_retry_max_attempts, 9 ) ;
242
278
assert_eq ! ( stored. max_table_sync_workers, 2 ) ;
243
279
}
244
280
}
0 commit comments