Recover jobs left InProgress when a node dies, without Redis

Offen
#47 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
18/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
csharp, mongodb, redis

Rechercherichtung

Start with how a node releases its own rows in src/TickerNet.EntityFrameworkCore/DependencyInjection/ServiceExtension.cs, then read NodeHeartBeatBackgroundService and ReleaseDeadNodeResources for the Redis path, and the row-claiming loop in src/TickerNet/Src/BackgroundServices/TickerNetSchedulerBackgroundService.cs. Done means a lease (LockedAt) is renewed while a job runs, a stale lease can be taken over without Redis, and late writes from a lost lease are rejected, across EF Core, MongoDB, Redis and in-memory providers. This needs an ADR in site/decisions/ before code.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

.NET enhancement roadmap

What happens

A job is marked InProgress with a LockHolder when a node starts it. If that node dies, the row stays InProgress until something releases it, and there are only two ways that happens:

  • With Redis, NodeHeartBeatBackgroundService notices the missing heartbeat and calls ReleaseDeadNodeResources for the dead node.
  • Without Redis, a node only releases its own rows when it starts again with the same NodeIdentifier (src/TickerNet.EntityFrameworkCore/DependencyInjection/ServiceExtension.cs). NodeIdentifier defaults to the machine name, which changes for every container or pod, so in most deployments the rows are never released.

Release also has a single outcome: the row goes back to Idle and runs again. A job that hangs on a live node is never released at all.

Separately, the scheduler marks every row it fetches as InProgress before it waits for a free worker slot (src/TickerNet/Src/BackgroundServices/TickerNetSchedulerBackgroundService.cs), so with a low MaxConcurrency many rows sit InProgress without running, and all of them are stranded if the node dies.

Expected

  • Work held by a node that's gone is recovered without Redis, based on time: for example the node renews a lease (LockedAt) while it runs the job, and any node may take over a row whose lease is older than a configurable timeout.
  • A per-function (or global) choice of what recovery does: run it again, or mark it failed. Jobs that aren't safe to repeat need the second.
  • An optional execution timeout that cancels a job running longer than allowed.

Notes

  • Mark a row InProgress only when a worker slot is taken; until then it stays claimed but not started.

  • Touches every provider: EF Core (BasePersistenceProvider), MongoDB, Redis and the in-memory provider.

  • Lease renewal must not run more often than needed; one update per running job every few seconds is the order of magnitude to aim for.

  • Late writes from a node that lost its lease must be rejected, so a recovered job isn't finished twice.


Part of the TickerQ comparison roadmap. Design it from this description only: never read or copy code, tests or docs from TickerQ 10.5.0 or later, which is under a commercial license (see CONTRIBUTING.md). If it adds or changes public API, add an ADR in site/decisions/ and list the API in the pull request. Comment here if you'd like to pick it up, and ask anything in Discussions.

Vorherrschende Sprache
C#
Sterne
0
Forks
2
Ø Merge
1 Std. 8 Min.
Gemergte PRs (30 T.)
24

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TickerNet/TickerNet

Alle Issues in TickerNet/TickerNet

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.