Skip to content

Error Recovery and Workflow Logs

The system includes multiple background recovery mechanisms and workflow engines to ensure data consistency under abnormal conditions. These logs help monitor the health status of background tasks.

When the service restarts or Turn execution is abnormally interrupted, the system automatically scans and recovers stale Turns.

EventTriggerKey Fields
[Server] recoverStaleTurns: found stale turnsStale Turns discoveredcount
[Server] recoverStaleTurns: published submitRecovery submission publishedturn
[Server] recoverStaleTurns: skip closed sessionSkip closed Sessionsession
[Server] recoverStaleTurns: skip already-interrupted turnSkip already interrupted Turnturn
[Server] recoverStaleTurns: requeued ghost workRe-queued ghost taskwork_id
[Server] recoverStaleTurns: released session lockSession lock releasedsession
[Server] recoverStaleTurns: skip lock release -- worker aliveSkip lock release (Worker still alive)session
[Server] periodicRecoverStaleTurns: found stale turnsPeriodic scan found stale Turnscount
[Server] periodicRecoverStaleTurns: checkpoint expiredCheckpoint expiredturn
[Server] periodicRecoverStaleTurns: recovering stale running/interrupted turnRecovering running/interrupted Turnturn
[Server] publishRecoveryWorkItem: publishedRecovery work item publishedsession, turn
EventTriggerKey Fields
[loop.Recovery] startedRecovery scan startedinterval
[loop.Recovery] cancelled expired loopCancelled expired Looploop_id
[loop.Recovery] re-enqueued stale loopRe-enqueued stalled Looploop_id
[loop.Cleanup] cancelled active loopCleaned up active Looploop_id
[loop.Cleanup] cancelled active goalCleaned up active Goalgoal_id
EventTriggerKey Fields
[turnagent] createLoop.completedLoop creation completedloop_id, session_id
[turnagent] createGoal.completedGoal creation completedgoal_id, session_id
[turnagent] pauseLoop.completedLoop pausedloop_id, session_id
[turnagent] resumeLoop.completedLoop resumedloop_id, session_id
[turnagent] listLoops.completedLoop list querysession_id, count
[turnagent] loopWorkflow.loop_exhaustedLoop reached maximum iterationsloop_id, session_id
[turnagent] loopWorkflow.loop_extendedLoop iteration extendedloop_id, session_id, iteration
[turnagent] loopWorkflow.scheduled_nextNext execution scheduledloop_id, task_id
[turnagent] goalWorkflow.goal_exhaustedGoal reached maximum iterationsgoal_id, session_id
[turnagent] goalWorkflow.goal_extendedGoal iteration extendedgoal_id, session_id, iteration
EventTriggerKey Fields
[lifecycle.Manager] component startedComponent started successfullycomponent
[lifecycle.Manager] component stoppedComponent stopped successfullycomponent
[lifecycle.Manager] start component failedComponent start failedcomponent, error
[lifecycle.Manager] stop component failedComponent stop failedcomponent, error
[lifecycle.Manager] shutdown timeoutShutdown timeout-
[lifecycle.Manager] goroutine panicComponent Goroutine exceptioncomponent, panic, stack
EventTriggerKey Fields
Starting RTC Agent server...Server starting-
HTTP server listeningHTTP server readyaddr
LLM initializedLLM initialization completedprovider, model
Tracing enabledTracing enabledendpoint, sample_rate
Shutting down server...Server shutting down-
Server failedServer startup failederror
Database migration completed successfullyDatabase migration completed-
EventTriggerKey Fields
goroutine leak threshold exceededGoroutine count exceeds thresholdcount, threshold
{service="server"} | json | msg=~"\\[Server\\] (recoverStaleTurns|periodicRecoverStaleTurns|publishRecoveryWorkItem)"
{service="server"} | json count="count" | msg=~"\\[Server\\] (recoverStaleTurns|periodicRecoverStaleTurns): found stale turns"

Trace recovery process for a specific Turn

Section titled “Trace recovery process for a specific Turn”
{service="server"} | json turn="turn" | msg=~"\\[Server\\] (recoverStaleTurns|periodicRecoverStaleTurns)" | turn="turn-123"
{service="server"} | json | msg=~"\\[Server\\] (recoverStaleTurns|periodicRecoverStaleTurns).*(failed|error)"
{service="server"} | json | msg=~"\\[loop\\.(Recovery|Cleanup)\\]"
{service="server"} | json | msg=~"\\[turnagent\\] (createLoop|createGoal|pauseLoop|resumeLoop|loopWorkflow|goalWorkflow)"
{service="server"} | json loop_id="loop_id" | msg=~"\\[turnagent\\] (createLoop|pauseLoop|resumeLoop|loopWorkflow|listLoops)" | loop_id="loop-abc"

View Loops that reached maximum iterations

Section titled “View Loops that reached maximum iterations”
{service="server"} | json | msg="[turnagent] loopWorkflow.loop_exhausted"

View Goals that reached maximum iterations

Section titled “View Goals that reached maximum iterations”
{service="server"} | json | msg="[turnagent] goalWorkflow.goal_exhausted"
{service="server"} | json component="component", error="error" | msg="[lifecycle.Manager] start component failed"
{service="server"} | json component="component", error="error" | msg="[lifecycle.Manager] stop component failed"
{service="server"} | json count="count", threshold="threshold" | msg="goroutine leak threshold exceeded"
{service="server"} | json | msg=~"Starting RTC Agent server|HTTP server listening|LLM initialized|Tracing enabled"
{service="server"} | json | msg=~"Shutting down server|centrifuge node shutdown|broker close|Server shutdown"
{service="server"} | json | msg=~"Running database migration|Database migration completed"

View shutdown timeouts (possible Goroutine leaks)

Section titled “View shutdown timeouts (possible Goroutine leaks)”
{service="server"} | msg="[lifecycle.Manager] shutdown timeout, goroutines still running"
{service="server"} | json panic="panic", stack="stack" | msg=~"panic recovered|panic|\\[Centrifuge\\] OnConnect panic"
MetricTypeLabelsPurpose
rtc_stale_turns_recovered_totalCounterstatusStale Turn recovery statistics
rtc_checkpoint_operations_totalCounteroperation, statusCheckpoint operation statistics
rtc_checkpoint_data_bytesHistogramoperationCheckpoint data size
# Stale Turns recovered per minute
sum(rate(rtc_stale_turns_recovered_total[5m])) by (status)
# Checkpoint operation rate
sum(rate(rtc_checkpoint_operations_total[5m])) by (operation, status)
AlertConditionDescription
Frequent Stale Turn recoveryRecovery > 30 per minuteService may be restarting frequently or Turn execution is unstable
Goroutine leakGoroutine count exceeds thresholdGoroutine leak detected
Component start failureConsecutive start failuresDependency service unavailable
Shutdown timeoutShutdown timeout appearsCheck for blocked Goroutines
Frequent Loop recoveryRecovery > 10 per minuteTask queue may have issues
  1. View recovery logs: {service="server"} | msg=~"recoverStaleTurns" | json
  2. Check if the service is restarting frequently: {service="server"} | msg="Starting RTC Agent server"
  3. Check if Workers are alive: {service="server"} | msg="skip lock release -- worker alive"
  4. If the service is healthy, check if Turn execution is timing out
  1. View workflow logs: {service="server"} | msg=~"loopWorkflow|goalWorkflow" | json
  2. Check Loop status: are there loop_exhausted events
  3. View recovery logs: {service="server"} | msg=~"\\[loop\\.(Recovery|Cleanup)\\]"
  4. Check if asynq tasks are executing normally
  1. View shutdown logs: {service="server"} | msg=~"Shutting down|stopped|shutdown"
  2. Check for timeouts: {service="server"} | msg="shutdown timeout"
  3. View Goroutine count: {service="server"} | msg="goroutine leak threshold exceeded"
  4. Export pprof: GET /debug/pprof/goroutine