Skip to content

Commit

Permalink
[ISSUE #468] Prevent schedule tasks from exiting due to exceptions (#469
Browse files Browse the repository at this point in the history
)
  • Loading branch information
RongtongJin authored Apr 7, 2023
1 parent 47d47e5 commit eb81225
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,21 @@ private void execScheduleTask() {
metricsMonitorExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
replicateLagMetric();
try {
replicateLagMetric();
} catch (Throwable e) {
log.error("replicate log metric error", e);
}
}
}, period, period, TimeUnit.MILLISECONDS);

commitOffsetScheduleService.scheduleAtFixedRate(new Runnable() {
@Override public void run() {
commitOffsetSchedule();
try {
commitOffsetSchedule();
} catch (Throwable e) {
log.error("commit offset error", e);
}
}
}, connectorConfig.getCommitOffsetIntervalMs(), connectorConfig.getCommitOffsetIntervalMs(), TimeUnit.MILLISECONDS);
}
Expand Down Expand Up @@ -366,14 +374,14 @@ public void accept(MessageQueue messageQueue, OffsetWrapper offsetWrapper) {
metricsItem2KeyMap.put(ReplicatorTaskStats.REPLICATOR_SOURCE_TASK_DELAY_NUMS, delayNumsKeys);
metricsItem2KeyMap.put(ReplicatorTaskStats.REPLICATOR_SOURCE_TASK_DELAY_MS, delayMsKeys);
} catch (RemotingException | MQClientException e) {
log.error(" occur remoting or mqclient exception, retry build mqadminclient,", e);
log.error("occur remoting or mqclient exception, retry build mqadminclient", e);
try {
buildMqAdminClient();
} catch (MQClientException mqClientException) {
log.error(" rebuild mqadminclient error,", e);
log.error("rebuild mqadmin client error", e);
}
} catch (Exception e) {
log.error(" occur unknow exception,", e);
log.error(" occur unknown exception", e);
}
}

Expand Down

0 comments on commit eb81225

Please sign in to comment.