{"record":{"id":"ae4db4b47a62ba1e","repo":"vitessio/vitess","slug":"failed-to-create-vcopier-worker-s","errorCode":null,"errorMessage":"failed to create vcopier worker: %s","messagePattern":"failed to create vcopier worker: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/vcopier.go","lineNumber":836,"sourceCode":"\n// open the work queue. The provided arguments are used to generate\n// statements for inserting rows and copy state.\nfunc (vcq *vcopierCopyWorkQueue) open(\n\tcopyStateInsert *sqlparser.ParsedQuery,\n\tpkfields []*querypb.Field,\n\ttablePlan *TablePlan,\n) {\n\tif vcq.isOpen {\n\t\treturn\n\t}\n\n\tpoolCapacity := int(math.Max(float64(vcq.maxDepth), 1))\n\tvcq.workerPool = pools.NewResourcePool(\n\t\t/* factory */\n\t\tfunc(ctx context.Context) (pools.Resource, error) {\n\t\t\tworker, err := vcq.workerFactory(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\t\"failed to create vcopier worker: %s\",\n\t\t\t\t\terr.Error(),\n\t\t\t\t)\n\t\t\t}\n\t\t\tworker.open(copyStateInsert, pkfields, tablePlan)\n\t\t\treturn worker, nil\n\t\t},\n\t\tpoolCapacity, /* initial capacity */\n\t\tpoolCapacity, /* max capacity */\n\t\t0,            /* idle timeout */\n\t\t0,            /* max lifetime */\n\t\tnil,          /* log wait */\n\t\tnil,          /* refresh check */\n\t\t0,            /* refresh interval */\n\t)\n\n\tvcq.isOpen = true\n}","sourceCodeStart":818,"sourceCodeEnd":854,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/vcopier.go#L818-L854","documentation":"The copy work queue's ResourcePool factory creates each vcopierCopyWorker by calling the user-supplied workerFactory (which opens a DB connection). Any failure there is wrapped as 'failed to create vcopier worker'. This is the pool-level wrapper around lower-level creation failures such as error 1395.","triggerScenarios":"ResourcePool factory invoked during queue open or worker replenishment while workerFactory fails — typically newClientConnection error, or a subsequent worker.open/setup failure.","commonSituations":"MySQL unreachable or out of connections during parallel copy startup; controller session settings invalid; engine shutdown racing worker creation.","solutions":["Look for the wrapped inner error (e.g. 'failed to create new db client') for the root cause","Fix MySQL connectivity/credentials, then restart the copy phase","Reduce parallelism so fewer simultaneous worker connections are needed","Retry after the database is healthy"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify DB connectivity and credentials before opening the copy queue\nmysql -h <db_host> -P <db_port> -u <user> -p -e 'SELECT 1'","typeGuard":null,"tryCatchPattern":"worker, err := pool.Get(ctx)\nif err != nil {\n  if strings.Contains(err.Error(), \"failed to create vcopier worker\") {\n    // inspect wrapped cause (db client creation) and retry after fix\n  }\n  return err\n}","preventionTips":["Reduce parallelism if the database rejects concurrent connections","Ensure the engine is not shutting down while workers are created","Watch logs for the inner 'failed to create new db client' cause"],"tags":["vreplication","vcopier","worker-pool","worker-creation"],"backgroundTag":"database-connection-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}