vitessio/vitess · error

PrimaryPosition(%s) failed: %w

Error message

PrimaryPosition(%s) failed: %w

What it means

Aggregated error recorded when fetching the primary's replication position (PrimaryPosition RPC) fails for reasons other than context cancellation or deadline exceeded. Such a non-timeout failure is treated as fatal for the whole request and recorded via errgroup.

Source

Thrown at go/vt/vtctl/grpcvtctldserver/server.go:4212

				span.Annotate("tablet_alias", alias)

				ctx, cancel := context.WithTimeout(ctx, topo.RemoteOperationTimeout)
				defer cancel()

				var status *replicationdatapb.Status

				pos, err := s.tmc.PrimaryPosition(ctx, tablet)
				if err != nil {
					switch ctx.Err() {
					case context.Canceled:
						log.Warn(fmt.Sprintf("context canceled before obtaining primary position from %s: %s", alias, err))
					case context.DeadlineExceeded:
						log.Warn(fmt.Sprintf("context deadline exceeded before obtaining primary position from %s: %s", alias, err))
					default:
						// The RPC was not timed out or canceled. We treat this
						// as a fatal error for the overall request.
						rec.RecordError(fmt.Errorf("PrimaryPosition(%s) failed: %w", alias, err))
						return
					}
				} else {
					// No error, record a valid status for this tablet.
					status = &replicationdatapb.Status{
						Position: pos,
					}
				}

				m.Lock()
				defer m.Unlock()

				results[alias] = status
				tabletMap[alias] = tablet
			}(ctx, alias, tabletInfo.Tablet)
		case tabletInfo.IsReplicaType():
			wg.Add(1)

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check the primary tablet's health and that vttablet/tabletmanager is running (`vtctldclient GetTablet <alias>`)
  2. Verify network connectivity between vtctld and the tablet's gRPC port
  3. Retry the operation once the tablet is back or the reparent completes
  4. If the primary alias is stale, repair the shard with a reparent

Example fix

// before
default:
    // The RPC was not timed out or canceled.
    rec.RecordError(fmt.Errorf("PrimaryPosition(%s) failed: %w", alias, err))
    return
// after
default:
    rec.RecordError(fmt.Errorf("PrimaryPosition(%s) failed: %w", alias, err))
    return
// (caller side) treat partially available statuses as degraded rather than failing:
statuses := rec.GetStatuses()
if len(statuses) == 0 { return nil, rec.GetError() }
Defensive patterns

Strategy: retry

Validate before calling

// verify primary tablet is serving before gathering positions
_, err := tmClient.Ping(ctx, primaryAlias)
if err != nil { /* primary unreachable; skip or wait */ }

Try / catch

try {
  positions = await client.getShardReplicationPositions(keyspace, shard)
} catch (e) {
  if (String(e).includes('PrimaryPosition')) {
    checkPrimaryHealth(); await backoffRetry(2)
  } else { throw e }
}

Prevention

When it happens

Trigger: A get-shard-replication-positions style request where the RPC to the primary tablet's tabletmanager (PrimaryPosition) fails with a connection error, tablet unavailable, or gRPC error — anything other than Canceled/DeadlineExceeded.

Common situations: Primary tablet is down or restarting during status gathering; tabletmanager port blocked by firewall/network partition; querying during a reparent when the old primary is unreachable.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/dc9bbcd293562785. Report an issue: GitHub.