fix(ugc): stopping the UGC server cancels the models being made

Stopping waited for every worker to finish its model, and with the path
traced hidden-face removal a big model takes minutes, so a restart hung.
UgcThrottle::Cancel(true) (set by UgcProcessor::Stop) makes Checkpoint,
which the long loops already call, throw UgcThrottle::Cancelled; the worker
abandons the job without writing or recording anything, so its row stays
waiting and is made again after the restart. The throttle's sleeps wake to
check it. Previews answer 503.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-28 19:36:16 -05:00
parent 4679edd2b2
commit 2277cbd7e2
4 changed files with 47 additions and 3 deletions

View File

@@ -14,9 +14,16 @@ namespace UgcThrottle {
void SetBudget(double cpus);
double GetBudget();
// Account the calling thread's CPU time and sleep when over the budget
// Account the calling thread's CPU time and sleep when over the budget. Throws Cancelled once Cancel(true) was
// called, so a job stops in moments when the server shuts down.
void Checkpoint();
// Thrown by Checkpoint while cancelled: the job is abandoned, not failed (its row stays waiting)
struct Cancelled {};
// Stop (true) or allow (false) every job's work: set when the server stops, cleared when it starts
void Cancel(bool cancel);
bool IsCancelled();
// Start accounting on this thread from now (a worker starting a job), so time spent idle isn't counted
void Begin();