Skip to content

Commit ed57899

Browse files
authored
Merge pull request #269 from brave/graceful-recovery-failure
Add separate max recovery failure threshold for top layer
2 parents 5d908ad + d61a17e commit ed57899

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/aggregator/processing.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use tokio::task::JoinHandle;
2222

2323
const TOTAL_RECOVERY_FAIL_MAX_MSGS_ENV: &str = "TOTAL_RECOVERY_FAIL_MAX_MSGS";
2424
const TOTAL_RECOVERY_FAIL_MAX_MSGS_DEFAULT: &str = "75";
25+
const TOTAL_RECOVERY_FAIL_TOP_LAYER_MAX_MSGS_ENV: &str = "TOTAL_RECOVERY_FAIL_TOP_LAYER_MAX_MSGS";
26+
const TOTAL_RECOVERY_FAIL_TOP_LAYER_MAX_MSGS_DEFAULT: &str = "500";
2527

2628
pub async fn process_expired_epoch(
2729
conn: Arc<Mutex<DBConnection>>,
@@ -221,12 +223,18 @@ fn process_one_layer(
221223
hex::encode(msg_tag),
222224
hex::encode(chunk.parent_msg_tag.clone().unwrap_or_default()),
223225
);
224-
if threshold_msgs_len
225-
<= parse_env_var::<usize>(
226+
let failure_max_threshold = match chunk.parent_msg_tag.is_some() {
227+
true => parse_env_var::<usize>(
226228
TOTAL_RECOVERY_FAIL_MAX_MSGS_ENV,
227229
TOTAL_RECOVERY_FAIL_MAX_MSGS_DEFAULT,
228-
)
229-
{
230+
),
231+
false => parse_env_var::<usize>(
232+
TOTAL_RECOVERY_FAIL_TOP_LAYER_MAX_MSGS_ENV,
233+
TOTAL_RECOVERY_FAIL_TOP_LAYER_MAX_MSGS_DEFAULT,
234+
),
235+
};
236+
237+
if threshold_msgs_len <= failure_max_threshold {
230238
total_error_count += threshold_msgs_len;
231239
continue;
232240
}

0 commit comments

Comments
 (0)