{"record":{"id":"a05d4229bcf8913d","repo":"apache/hadoop","slug":"hadoopreadzero-failed-with-error-code-d-s-n","errorCode":null,"errorMessage":"hadoopReadZero failed with error code %d (%s)\\n","messagePattern":"hadoopReadZero failed with error code (.+?) \\((.+?)\\)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c","lineNumber":591,"sourceCode":"}\n\n#endif\n\nstatic int vecsum_zcr_loop(int pass, struct libhdfs_data *ldata,\n        struct hadoopRzOptions *zopts,\n        const struct options *opts)\n{\n    int32_t len;\n    double sum = 0.0;\n    const double *buf;\n    struct hadoopRzBuffer *rzbuf = NULL;\n    int ret;\n\n    while (1) {\n        rzbuf = hadoopReadZero(ldata->file, zopts, ZCR_READ_CHUNK_SIZE);\n        if (!rzbuf) {\n            ret = errno;\n            fprintf(stderr, \"hadoopReadZero failed with error \"\n                \"code %d (%s)\\n\", ret, strerror(ret));\n            goto done;\n        }\n        buf = hadoopRzBufferGet(rzbuf);\n        if (!buf) break;\n        len = hadoopRzBufferLength(rzbuf);\n        if (len < ZCR_READ_CHUNK_SIZE) {\n            fprintf(stderr, \"hadoopReadZero got a partial read \"\n                \"of length %d\\n\", len);\n            ret = EINVAL;\n            goto done;\n        }\n        sum += vecsum(buf,\n            ZCR_READ_CHUNK_SIZE / sizeof(double));\n        hadoopRzBufferFree(ldata->file, rzbuf);\n    }\n    printf(\"finished zcr pass %d.  sum = %g\\n\", pass, sum);\n    ret = 0;","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c#L573-L609","documentation":"In zero-copy-read mode vecsum calls hadoopReadZero() (hdfsReadZero API); a NULL return means the zero-copy read failed and errno holds the reason. Zero-copy reads require short-circuit reads to be enabled and working (dfs.client.read.shortcircuit=true plus a valid dfs.domain.socket.path) and the file opened O_RDONLY; otherwise you get ENOTSUP/EPROTONOSUPPORT-style failures.","triggerScenarios":"Running 'vecsum -t zcr' against a cluster where dfs.client.read.shortcircuit is false, dfs.domain.socket.path is unset/misconfigured or its directory has wrong ownership/permissions, the DataNode does not have the matching dfs.datanode.domain.socket.path, or the domain socket connection failed at read time.","commonSituations":"Performance-testing zero-copy reads on a cluster where domain sockets were never set up; the domain socket directory was created by root so the hadoop user cannot connect; secure-cluster configs where short-circuit was disabled for security.","solutions":["Enable dfs.client.read.shortcircuit=true and set dfs.domain.socket.path on the client config used by vecsum.","Ensure the DataNode is configured with a matching dfs.datanode.domain.socket.path and that the socket directory is owned/group-accessible for the DFS clients (commonly root:hadoop 755 or 0755 parents).","Verify with the short-circuit smoke test or check DataNode logs for unix domain socket errors.","Until configured, run 'vecsum -t libhdfs' (normal buffered reads) instead of -t zcr."],"exampleFix":"# before: hdfs-site.xml used by the client\n<property><name>dfs.client.read.shortcircuit</name><value>false</value></property>\n# after\n<property><name>dfs.client.read.shortcircuit</name><value>true</value></property>\n<property><name>dfs.domain.socket.path</name><value>/var/lib/hadoop-hdfs/dn_socket</value></property>","handlingStrategy":"fallback","validationCode":"/* probe the precondition: this config must be present for zero-copy */\n/* (libhdfs has no direct getter — validate the XML the binary will load) */\n/* e.g. hdfs getconf -confKey dfs.client.read.shortcircuit  => must print true */","typeGuard":null,"tryCatchPattern":"rzbuf = hadoopReadZero(file, zopts, ZCR_READ_CHUNK_SIZE);\nif (!rzbuf) {\n    int err = errno;\n    if (err == ENOTSUP || err == EPROTONOSUPPORT) {\n        /* zero-copy unavailable on this setup: degrade to buffered reads */\n        ret = vecsum_libhdfs(ldata, opts);\n    } else {\n        /* real failure: report err */\n    }\n}","preventionTips":["Before -t zcr runs, confirm dfs.client.read.shortcircuit=true and a valid dfs.domain.socket.path on both client and DataNode.","Verify the domain-socket directory ownership/permissions (accessible to the DFS client user) before starting benchmarks.","Smoke-test zero-copy with a tiny aligned file before long runs.","Keep a -t libhdfs fallback path in benchmark scripts for clusters where short-circuit is disabled."],"tags":["hdfs","libhdfs","zero-copy","short-circuit","domain-socket","errno","vecsum"],"backgroundTag":"short-circuit-read-misconfigured","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}