vitessio/vitess · error

InsertRecoveryDetection: no detection_id returned for alias=

Error message

InsertRecoveryDetection: no detection_id returned for alias=%s analysis=%s

What it means

InsertRecoveryDetection records a newly detected recovery incident in the vtorc backend and expects the INSERT to return the new detection id (stored as analysisEntry.RecoveryId). If the insert succeeds but returns no id (RecoveryId == 0), VTOrc treats it as an inconsistent write and errors out so the incident is not tracked with a dangling identity.

Source

Thrown at go/vt/vtorc/logic/topology_recovery_dao.go:73

			?,
			DATETIME('now')
		)
		ON CONFLICT(alias, analysis) DO UPDATE
		SET detection_timestamp = DATETIME('now'),
		    keyspace = excluded.keyspace,
		    shard = excluded.shard
		RETURNING detection_id`,
		sqlutils.Args(aliasStr, analysisStr, analysisEntry.AnalyzedKeyspace, analysisEntry.AnalyzedShard),
		func(m sqlutils.RowMap) error {
			analysisEntry.RecoveryId = m.GetInt64("detection_id")
			return nil
		})
	if err != nil {
		log.Error(err.Error())
		return err
	}
	if analysisEntry.RecoveryId == 0 {
		err = fmt.Errorf("InsertRecoveryDetection: no detection_id returned for alias=%s analysis=%s", aliasStr, analysisStr)
		log.Error(err.Error())
		return err
	}
	return nil
}

func writeTopologyRecovery(topologyRecovery *TopologyRecovery) (*TopologyRecovery, error) {
	analysisEntry := topologyRecovery.AnalysisEntry
	sqlResult, err := db.ExecVTOrc(`INSERT OR IGNORE
		INTO topology_recovery (
			recovery_id,
			alias,
			start_recovery,
			analysis,
			keyspace,
			shard,
			detection_id
		) VALUES (

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check VTOrc logs for the logged error and inspect the DB to see whether the detection row was actually inserted
  2. Confirm the backend supports returning the inserted id (MySQL LAST_INSERT_ID) and the DAO query is intact for your Vitess version
  3. Resolve concurrent VTOrc instances writing the same detection; ensure only one instance owns recovery per cluster
  4. Restart VTOrc to re-detect and insert the incident cleanly; delete orphan detection rows if needed
Defensive patterns

Strategy: validation

Validate before calling

// Ensure backend supports returning insert ids
var id int64
if err := db.QueryRow("SELECT LAST_INSERT_ID()").Scan(&id); err != nil || id == 0 {
    return fmt.Errorf("backend cannot return detection id")
}

Prevention

When it happens

Trigger: executeCheckAndRecoverFunction (or tests) calls InsertRecoveryDetection and the underlying DAO insert (Generate/RETURNING detection_id style query) does not yield a row id — e.g. backend lacks RETURNING support semantics, or the write was a no-op update on an existing detection.

Common situations: Running against an unexpected/older backend that doesn't return last-insert-id as expected; a race where another VTOrc instance inserted the same detection concurrently; DB driver/version quirks with LAST_INSERT_ID().

Related errors


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