temporalio/temporal · error

error while fetching cluster metadata: %w

Error message

error while fetching cluster metadata: %w

What it means

Wraps the persistence error returned when fetching the current cluster metadata record fails in the default branch of the cluster metadata initialization switch. A persistence read (GetClusterMetadata) failed while bootstrapping cluster metadata, excluding the record-not-found case (handled by init branches).

Source

Thrown at temporal/fx.go:761

		// Ignore invalid cluster metadata
		overwriteCurrentClusterMetadataWithDBRecord(
			svc,
			resp,
			logger,
		)
	case *serviceerror.NotFound:
		// Initialize current cluster record
		if initErr := initCurrentClusterMetadataRecord(
			ctx,
			clusterMetadataManager,
			svc,
			indexSearchAttributes,
			logger,
		); initErr != nil {
			return svc.ClusterMetadata, svc.Persistence, initErr
		}
	default:
		return svc.ClusterMetadata, svc.Persistence, fmt.Errorf("error while fetching cluster metadata: %w", err)
	}

	clusterLoader := NewClusterMetadataLoader(clusterMetadataManager, logger)
	err = clusterLoader.LoadAndMergeWithStaticConfig(ctx, svc)
	if err != nil {
		return svc.ClusterMetadata, svc.Persistence, fmt.Errorf("error while loading metadata from cluster: %w", err)
	}
	return svc.ClusterMetadata, svc.Persistence, nil
}

func initCurrentClusterMetadataRecord(
	ctx context.Context,
	clusterMetadataManager persistence.ClusterMetadataManager,
	svc *config.Config,
	initialIndexSearchAttributes map[string]*persistencespb.IndexSearchAttributes,
	logger log.Logger,
) error {
	var clusterId string

View on GitHub (pinned to bde624efd1)

Solutions

  1. Inspect the wrapped root error for the driver-specific cause
  2. Check database availability and network reachability from the server hosts
  3. Verify schema versions match using temporal-cassandra-tool / sql-tool validate
  4. Retry startup after restoring DB connectivity
Defensive patterns

Strategy: retry

Validate before calling

// pre-start DB health check
if err := db.PingContext(ctx); err != nil {
    return fmt.Errorf("metadata DB unreachable: %w", err)
}

Try / catch

err := startServer(ctx)
if err != nil && strings.Contains(err.Error(), "error while fetching cluster metadata") {
    return retry.Do(func() error { return startServer(ctx) }, retry.Attempts(3))
}

Prevention

When it happens

Trigger: Server startup calls the cluster metadata provider; GetClusterMetadata returns a non-not-found error — DB connectivity loss, timeout, or internal persistence failure.

Common situations: Cassandra/Postgres/MySQL outage or network partition during startup; schema mismatch causing driver errors; persistence layer timeouts under load.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/6139e420499f7800. Report an issue: GitHub.