Skip to content

DuoWorkflowSessionCreditsSyncStale

This playbook covers both freshness alerts of the v2 Duo Agent Platform session credits sync:

AlertFires when
DuoWorkflowSessionCreditsSyncStaleA top-level group in scope has not had a complete sync for more than 18 hours
DuoWorkflowSessionCreditsSyncFirstSyncOverdueA top-level group has been in scope for more than 7 days without any complete sync

The sync copies Duo Agent Platform credit usage from CustomersDot into ClickHouse. A group is in scope when CustomersDot billed it for Duo Agent Platform sessions in the last 90 days.

  • Every 6 hours, Ai::DuoWorkflows::SyncSessionCreditsCronWorker lists the groups in scope from the CustomersDot sessionNamespaces query and enqueues one Ai::DuoWorkflows::SyncNamespaceSessionCreditsWorker job per group in scope.
  • A job that reads every page CustomersDot has for the group completes the sync (stop_reason: completed). A job that runs out of its 120-second budget stops with over_time and continues on the next tick.
  • At the start of every tick, the cron observes each group in scope: how long ago its last complete sync was, or, for a group with no complete sync since it entered scope, how long it has been waiting.

When an alert fires, credit usage in GitLab is stale or missing for some groups. Find which groups and why (see Troubleshooting), then act on the cause.

Two histograms, observed once per group in scope at the start of every tick. Both have bucket edges at 6h, 12h, 16h, 18h, 24h, 48h and 7 days.

  • duo_workflow_session_credits_v2_sync_age_seconds: seconds since the group’s last complete sync.
  • duo_workflow_session_credits_v2_awaiting_sync_seconds: seconds a group has been in scope without a complete sync.

Each alert counts the observations above its threshold in the last 7 hours, one tick plus slack: the +Inf bucket’s increase minus the threshold bucket’s.

  • 18 hours allows two missed ticks. A group that completes every tick is under 6 hours old at the next tick, and each missed tick adds 6 hours, so over 18 hours means the last three ticks did not complete.
  • 7 days for groups awaiting a first sync, because a new group reads up to 90 days of sessions and can take several ticks to finish. That is normal for groups new to Duo Agent Platform.

Under normal conditions both counts are 0.

  • Both alerts are s3: they do not page, and in gprd go to #g_analytics_optimize.
  • An alert fires 10 to 15 minutes after the tick that observed the group and clears 7 hours after the last tick that still sees it over the threshold.
  • The alerts measure only groups in scope. A group that CustomersDot stops listing drops out of scope after two ticks and is not alerted on.
  • The alerts measure nothing, and stay silent, if the cron does not run, if ClickHouse analytics is disabled, if the cron cannot list groups from CustomersDot (stop_reason: cdot_error on its done line), or if Redis SharedState fails during the tick (the done line then has no oldest_* fields). A CustomersDot outage that only fails the namespace jobs does not stop the measurement: the cron still observes every group in scope while their syncs fail.
  • A group CustomersDot has no subscription for (failure_reason: no_cdot_subscription_found) counts as synced: there is nothing in CustomersDot to go stale.
  • Only a job that reads every page completes a sync. A group whose jobs end with over_time, rate_limited, undefined_field or no_billable_license on every tick never completes, so it can be stale or awaiting a first sync while the failed syncs alert stays silent.
  • Impact: customers of the affected top-level groups see stale or missing Duo Agent Platform credit usage in GitLab. Billing data in CustomersDot is not affected.
  • Incident severity: usually S4. Raise to S3 if many groups are affected, or customers report it.

Groups over the threshold per tick:

sum by (env) (increase(duo_workflow_session_credits_v2_sync_age_seconds_bucket{env="gprd", le="+Inf"}[7h]))
-
sum by (env) (increase(duo_workflow_session_credits_v2_sync_age_seconds_bucket{env="gprd", le=~"64800|64800.0"}[7h]))

Replace the metric with duo_workflow_session_credits_v2_awaiting_sync_seconds and the edge with 604800 for groups awaiting a first sync.

Kibana, pubsub-sidekiq-inf-gprd index, cron done lines:

json.class: "Ai::DuoWorkflows::SyncSessionCreditsCronWorker" and json.job_status: "done"

Under json.extra.ai_duo_workflows_sync_session_credits_cron_worker.*:

  • oldest_sync_age_s: the oldest last complete sync among synced groups, in seconds.
  • namespaces_awaiting_sync and oldest_awaiting_sync_s: groups waiting for a first sync, and the longest wait.
  • namespaces_enumerated, namespaces_enqueued, namespace_jobs_buffered and stop_reason.
  1. Check whether the failed syncs alert or a concurrency limit alert for Ai::DuoWorkflows::SyncNamespaceSessionCreditsWorker (such as SidekiqConcurrencyLimitQueueGrowing) is firing too. They usually name the cause.

  2. Find the affected groups. In Kibana, take the namespace job done lines of the last day and look for groups whose runs never end in stop_reason: completed:

    json.class: "Ai::DuoWorkflows::SyncNamespaceSessionCreditsWorker" and json.job_status: ("done" or "fail")

    Break the results down by json.extra.ai_duo_workflows_sync_namespace_session_credits_worker.root_namespace_id and stop_reason.

  3. For one group, read its freshness record in a Rails console:

    Ai::DuoWorkflows::SessionCredits::SyncFreshness.status(<root_namespace_id>)
    # => { last_completed_at:, last_seen_in_scope_at:, in_scope_since: }
  4. Act on what the group’s runs show:

Runs of the groupLikely causeAction
stop_reason: error with failure_reason server_error or connection_error for many groupsCustomersDot outageFollow the failed syncs playbook. The groups recover on the first tick after CustomersDot does.
stop_reason: rate_limitedCustomersDot rate-limited the group’s job; the next tick resumes from the stored page tokenAct only if it repeats for many groups: contact the Fulfillment team in #g_monetization_platform.
stop_reason: errorA failure specific to the group, named by failure_reasonFollow the failure_reason table in the failed syncs playbook.
stop_reason: interruptedSidekiq shut down mid-job, for example during a deploy, and re-queued itExpected on deploy-heavy days. Act only if it repeats for the same group on quiet days.
stop_reason: over_time on every tickThe group has more sessions than one 120-second job can read; cursor_lag_s keeps growingExpected for a few ticks after the group enters scope. If it never catches up, open an issue: the job budget or page size may need tuning for the group.
No runs at allThe job never ran, usually queued behind the concurrency limitCheck namespace_jobs_buffered on the cron’s done line and the worker’s concurrency limit queue.
  • CustomersDot outage: the groups recover on their own on the first tick after CustomersDot does.
  • CustomersDot GraphQL sessionNamespaces and sessions queries.
  • ClickHouse (duo_workflow_session_enrichments, sync_cursors).
  • Redis SharedState (freshness records, page tokens).
  • group::optimize in #g_analytics_optimize.
  • CustomersDot problems: the Fulfillment team in #g_monetization_platform.