goharbor/harbor · error

failed to count running executions for policy ID

Error message

failed to count running executions for policy ID: %d: %v

What it means

Replication Start wraps the execMgr.Count query used to enforce SingleActiveReplication. If counting currently-running executions for the policy fails (DB error), Start aborts rather than risk starting a duplicate active replication.

Solutions

  1. Check database connectivity and health of the execution manager's backing store
  2. Retry starting the replication once the DB recovers
  3. Inspect logs for the wrapped underlying error from the Count query
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/controller/replication/execution.go:125 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/fbbcbdc3dfb80ebd. Report an issue: GitHub.

Appendix: source

Thrown at src/controller/replication/execution.go:125

	// create an execution record
	extra := make(map[string]any)
	if op := operator.FromContext(ctx); op != "" {
		extra["operator"] = op
	}

	var count int64
	// If running executions are found, skip the current execution and mark it as error.
	if policy.SingleActiveReplication {
		var err error
		count, err = c.execMgr.Count(ctx, &q.Query{
			Keywords: map[string]any{
				"VendorType": job.ReplicationVendorType,
				"VendorID":   policy.ID,
				"Status":     job.RunningStatus.String(),
			},
		})
		if err != nil {
			return 0, fmt.Errorf("failed to count running executions for policy ID: %d: %v", policy.ID, err)
		}
	}

	id, err := c.execMgr.Create(ctx, job.ReplicationVendorType, policy.ID, trigger, extra)
	if err != nil {
		return 0, err
	}

	if policy.SingleActiveReplication {
		if count > 0 {
			if err = c.execMgr.MarkError(ctx, id, "Execution skipped: active replication still in progress."); err != nil {
				return 0, err
			}
			return id, nil
		}
	}

	// start the replication flow in background

View on GitHub (pinned to 7b2fd08cc5)