Class: ChronoForge::Dashboard::StrandedController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/chrono_forge/dashboard/stranded_controller.rb

Overview

Workflows stranded in :running — still locked, but their lock hasn't been refreshed within reap_stale_after, so no worker is driving them (the worker was hard-killed mid-pass). This is exactly the set ChronoForge::Workflow .reap_stalled re-enqueues; the page reads the reaper's own criterion so the two never disagree. Top-level and branch children alike, like the reaper.

Constant Summary collapse

CAP =

Bound the scan: at scale there can be a large backlog, so we examine at most CAP (oldest lock first — most stranded) and let the bulk reap sweep the rest server-side.

500

Instance Method Summary collapse

Instance Method Details

#indexObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/chrono_forge/dashboard/stranded_controller.rb', line 14

def index
  cutoff = ChronoForge.config.reap_stale_after.ago
  scope = ChronoForge::Workflow
    .where(state: ChronoForge::Workflow.states[:running])
    .where(locked_at: ...cutoff)
    .order(locked_at: :asc)
    .limit(CAP + 1)
    .to_a
  @capped = scope.size > CAP
  @stranded = scope.first(CAP)
  @cap = CAP
  @stale_after = ChronoForge.config.reap_stale_after
end