Billionmail/BillionMail · critical

failed to get all domains: %v

Error message

failed to get all domains: %v

What it means

RepairDKIMSigningConfig aborts when the dao-level All(ctx) call fails to enumerate all domains, which is step 1 of the DKIM signing repair sweep. The wrapped DB error surfaces with this message to callers like SyncRelayConfigsToPostfix.

Source

Thrown at core/internal/service/domains/domains.go:911

		}
	} else {
		records.PTR, _ = GetPTRRecord(domain, false)
	}

	return
}

// RepairDKIMSigningConfig repairs the DKIM signing configuration file.
func RepairDKIMSigningConfig(ctx context.Context) error {
	g.Log().Debug(ctx, "Repairing DKIM signing config...")
	defer func() {
		g.Log().Debug(ctx, "Repairing DKIM signing config completed.")
	}()

	// 1. Get all domains
	ds, err := All(ctx)
	if err != nil {
		return fmt.Errorf("failed to get all domains: %v", err)
	}

	// 1b. Get relay-mapped domains to exclude from DKIM signing
	relayDomains, err := GetRelayDomains(ctx)
	if err != nil {
		g.Log().Warningf(ctx, "Failed to get relay domains, signing all: %v", err)
		relayDomains = make(map[string]bool)
	}

	// 2. Build the full DKIM config content
	var allSignConfBlocks strings.Builder
	for _, d := range ds {
		// Skip domains with active relay — relay provider signs DKIM
		if relayDomains[d.Domain] {
			g.Log().Debugf(ctx, "Skipping DKIM signing for relay-mapped domain: %s", d.Domain)
			continue
		}
		// Regenerate missing DKIM key files

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Verify PostgreSQL is up and reachable (docker ps, pg_isready) and fix connection settings if not
  2. Run pending migrations and confirm the domains table exists with the expected schema
  3. Check DB credentials in the app configuration and test the connection manually
  4. Inspect DB logs for locks/errors, then re-run RepairDKIMSigningConfig

Example fix

// before: bare DB failure aborts repair
ds, err := All(ctx)
if err != nil {
    return fmt.Errorf("failed to get all domains: %v", err)
}
// after: ensure DB is ready before repair
if err := g.DB().Ping(ctx); err != nil {
    return fmt.Errorf("database unavailable, run migrations/start postgres: %w", err)
}
ds, err := All(ctx)
Defensive patterns

Strategy: retry

Validate before calling

if err := g.DB().Ping(ctx); err != nil {
    return fmt.Errorf("postgres unreachable, start it or check credentials before repair: %w", err)
}

Try / catch

ds, err := All(ctx)
if err != nil {
    log.Printf("domain enumeration failed: %v — retrying after backoff", err)
    select {
    case <-time.After(5 * time.Second):
    case <-ctx.Done():
        return ctx.Err()
    }
    return RepairDKIMSigningConfig(ctx)
}

Prevention

When it happens

Trigger: All(ctx) returns a database error — Postgres unreachable, connection pool exhausted, table missing/corrupted, schema migration pending, query timeout, or context cancellation.

Common situations: Database container stopped or restarting, wrong DB credentials after a config change, migration not run after upgrade, network partition between app and Postgres, long transaction/lock blocking the domain table read.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/82d97a52b870756d. Report an issue: GitHub.