vitessio/vitess · warning

unable to connect to the database when attempting to kill th

Error message

unable to connect to the database when attempting to kill the connection executing post copy actions: %v

What it means

To interrupt an in-flight post copy action (e.g. a long ALTER TABLE), VReplication opens a fresh DBA connection to issue 'KILL <connID>'. This error is returned when that DBA connection cannot be established within a bounded 10-second timeout, and is logged (not fatal) — the in-flight action is then left to complete as it would have before interruption support existed.

Source

Thrown at go/vt/vttablet/tabletmanager/vreplication/vreplicator.go:1033

	// killActionsConnection is deliberately independent of which
	// action -- if any -- is currently executing so that a
	// cancellation which arrives between actions cannot be lost.
	// Non-SQL action types, if ever added, will need their own
	// interruption mechanism.
	killActionsConnection := func() error {
		if connID < 1 {
			return fmt.Errorf("invalid connection ID found (%d) when attempting to kill the connection executing post copy actions", connID)
		}
		// The attempt is bounded: the connection setup honors the
		// context, and if the KILL query itself stalls the goroutine
		// below closes the connection, which unblocks it. We don't
		// parent this context on the ones whose cancellation got us
		// here -- they are already done -- but we keep their values.
		killCtx, cancel := context.WithTimeout(context.WithoutCancel(stopCtx), killActionsConnectionTimeout)
		defer cancel()
		killdbc, err := vr.mysqld.GetDbaConnection(killCtx)
		if err != nil {
			return fmt.Errorf("unable to connect to the database when attempting to kill the connection executing post copy actions: %v", err)
		}
		defer killdbc.Close()
		go func() {
			// killCtx is always cancelled when the attempt returns, so
			// this goroutine cannot leak. Close is idempotent and safe
			// to call concurrently with an in-flight query.
			<-killCtx.Done()
			killdbc.Close()
		}()
		_, kerr := killdbc.ExecuteFetch(fmt.Sprintf("kill %d", connID), 1, false)
		return kerr
	}
	go func() {
		var reason string
		select {
		// Only kill the connection executing the post copy actions
		// if the engine is closing or the controller is stopping.
		case <-vr.vre.ctx.Done():

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check MySQL max_connections and connection usage; kill stale connections or raise the limit
  2. Verify the tablet's DBA credentials/connection config (mysqld GetDbaConnection settings) are correct
  3. Check MySQL health/latency — a stalled server also stalls the KILL attempt; restart/recover mysqld if hung
  4. This is non-fatal by design: the original action completes or is retried on workflow restart; just retry the interrupted operation (PRS, workflow delete) after MySQL is healthy
Defensive patterns

Strategy: retry

Validate before calling

// Verify DBA connectivity before relying on interruption:
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn, err := mysqld.GetDbaConnection(ctx)
if err != nil { /* DBA path unhealthy: fix credentials/max_connections first */ }
conn.Close()

Try / catch

if err := killActionsConnection(); err != nil {
    // logged, not fatal — retry the interrupted operation once MySQL is reachable
    retryOperation()
}

Prevention

When it happens

Trigger: During engine shutdown or workflow stop/delete/update, killActionsConnection calls vr.mysqld.GetDbaConnection(killCtx) and it fails — DBA credentials misconfigured, too many MySQL connections, MySQL unresponsive, or the 10s killActionsConnectionTimeout expires first.

Common situations: MySQL at max_connections limit under heavy load; stalled/unresponsive mysqld during PRS; dba user misconfigured on the tablet (--db-credentials / dba server config); network issues between tablet and MySQL.

Related errors


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