1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-23 00:16:25 +01:00

fix: schduler-service graceful shutdown (#6125)

When a stop signal is sent to Unleash the scheduler-service should
cancel any scheduled jobs. This also applies to the job scheduled for
initial execution with jitter.


We observed that initial jobs was executed after the database
connections are terminated. This appears after v5.9.0 of Unleash.

```
Error: aborted
    at Object.queryBuilder (/unleash/node_modules/knex/lib/knex-builder/make-knex.js:112:26)
    at createQueryBuilder (/unleash/node_modules/knex/lib/knex-builder/make-knex.js:320:26)
    at EventStore.knex [as db] (/unleash/node_modules/knex/lib/knex-builder/make-knex.js:101:12)
    at EventStore.setUnannouncedToAnnounced (/unleash/node_modules/unleash-server/dist/lib/features/events/event-store.js:286:33)
    at EventStore.publishUnannouncedEvents (/unleash/node_modules/unleash-server/dist/lib/features/events/event-store.js:293:35)
    at EventAnnouncer.publishUnannouncedEvents (/unleash/node_modules/unleash-server/dist/lib/services/event-announcer-service.js:9:32)
    at runScheduledFunctionWithEvent (/unleash/node_modules/unleash-server/dist/lib/features/scheduler/scheduler-service.js:30:23)
    at Timeout.<anonymous> (/unleash/node_modules/unleash-server/dist/lib/features/scheduler/scheduler-service.js:50:27)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processTimers (node:internal/timers:509:9)
```
This commit is contained in:
Ivar Conradi Østhus 2024-02-05 11:04:13 +01:00 committed by GitHub
parent 73c4c62ea3
commit 354b88383c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,9 +93,11 @@ export class SchedulerService {
if (!maintenanceMode) {
if (jitter) {
setTimeout(() => {
runScheduledFunctionWithEvent();
}, jitter);
const id = setTimeout(
() => runScheduledFunctionWithEvent(),
jitter,
);
this.intervalIds.push(id);
} else {
await runScheduledFunctionWithEvent();
}