{"record":{"id":"112ab4bd3599bc26","repo":"juicedata/juicefs","slug":"read-worker-config-s","errorCode":null,"errorMessage":"read worker config: %s","messagePattern":"read worker config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/cluster.go","lineNumber":414,"sourceCode":"\t})\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"marshal worker config: %s\", err)\n\t}\n\n\targs := []string{host, path}\n\targs = append(args, workerArgs...)\n\targs = append(args, \"--manager\", address)\n\tif !config.Verbose && !config.Quiet {\n\t\targs = append(args, \"-q\")\n\t}\n\treturn shellescape.EscapeArgs(args), payload, nil\n}\n\n// ReadClusterWorkerConfig reads storage URLs and environment variables from worker stdin.\nfunc ReadClusterWorkerConfig(r io.Reader) (string, string, map[string]string, error) {\n\tdata, err := io.ReadAll(io.LimitReader(r, maxClusterWorkerConfigSize+1))\n\tif err != nil {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"read worker config: %s\", err)\n\t}\n\tif len(data) > maxClusterWorkerConfigSize {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"worker config is too large\")\n\t}\n\tvar config clusterWorkerConfig\n\tif err := json.Unmarshal(data, &config); err != nil {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"unmarshal worker config: %s\", err)\n\t}\n\tif config.Source == \"\" || config.Destination == \"\" {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"worker config is missing source or destination\")\n\t}\n\treturn config.Source, config.Destination, config.Env, nil\n}\n\nfunc launchWorker(address string, config *Config, wg *sync.WaitGroup) {\n\tworkers := strings.Split(strings.Join(config.Workers, \",\"), \",\")\n\tfor _, host := range workers {\n\t\twg.Add(1)","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/sync/cluster.go#L396-L432","documentation":"ReadClusterWorkerConfig reads the worker config (storage URLs + env) that the manager pipes over the worker's stdin. This error wraps any failure reading that stdin stream (io.ReadAll on a limited reader), e.g. the pipe was closed early or the reader returned an I/O error.","triggerScenarios":"The worker process's stdin pipe errors or is closed prematurely before EOF while ReadClusterWorkerConfig reads up to maxClusterWorkerConfigSize+1 bytes — e.g. manager died mid-write, SSH connection dropped, or a broken pipe on the transport.","commonSituations":"SSH connection to the manager drops during cluster sync startup; the manager process is killed while launching workers; stdin redirected from a file/pipe that errors or is already closed.","solutions":["Re-run the sync and check the manager side for crashes or network drops","Verify the SSH transport to workers is stable (no aggressive timeouts, keepalives enabled)","Check that nothing else consumes or closes the worker's stdin (shell redirections, wrapper scripts)","If persistent, inspect disk/OS-level pipe errors on the worker host"],"exampleFix":"// before (wrapper consuming stdin)\nssh worker 'somecmd | juicefs sync ...'\n// after (pass manager payload via stdin untouched)\nssh worker 'juicefs sync ... --manager host:port' < config.json","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"src, dst, env, err := sync.ReadClusterWorkerConfig(os.Stdin)\nif err != nil {\n\tif strings.Contains(err.Error(), \"read worker config\") {\n\t\tlogger.Fatalf(\"worker stdin transport failed: %v — check manager liveness and SSH stability\", err)\n\t}\n\tlogger.Fatalf(\"worker config error: %v\", err)\n}","preventionTips":["Don't redirect or consume the worker's stdin with wrappers or pipelines","Ensure the manager host and network are stable during worker startup","Monitor SSH keepalive/timeout settings for long cluster syncs"],"tags":["sync","cluster","io","stdin"],"backgroundTag":"file-read-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}