{"record":{"id":"33c32d7e05863c3e","repo":"apache/hadoop","slug":"hdfsread-failed-and-set-errno-d","errorCode":null,"errorMessage":"hdfsRead failed and set errno %d\n","messagePattern":"hdfsRead failed and set errno (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c","lineNumber":267,"sourceCode":"    errno = 0;\n    EXPECT_UINT64_EQ(UINT64_C(0), readStats->totalBytesRead);\n    EXPECT_UINT64_EQ(UINT64_C(0), readStats->totalLocalBytesRead);\n    EXPECT_UINT64_EQ(UINT64_C(0), readStats->totalShortCircuitBytesRead);\n    hdfsFileFreeReadStatistics(readStats);\n\n    /* Verify that we can retrieve the hedged read metrics */\n    EXPECT_ZERO(hdfsGetHedgedReadMetrics(fs, &hedgedMetrics));\n    errno = 0;\n    EXPECT_UINT64_EQ(UINT64_C(0), hedgedMetrics->hedgedReadOps);\n    EXPECT_UINT64_EQ(UINT64_C(0), hedgedMetrics->hedgedReadOpsWin);\n    EXPECT_UINT64_EQ(UINT64_C(0), hedgedMetrics->hedgedReadOpsInCurThread);\n    hdfsFreeHedgedReadMetrics(hedgedMetrics);\n\n    /* TODO: implement readFully and use it here */\n    ret = hdfsRead(fs, file, tmp, sizeof(tmp));\n    if (ret < 0) {\n        ret = errno;\n        fprintf(stderr, \"hdfsRead failed and set errno %d\\n\", ret);\n        return ret;\n    }\n    if (ret != expected) {\n        fprintf(stderr, \"hdfsRead was supposed to read %d bytes, but \"\n                \"it read %d\\n\", ret, expected);\n        return EIO;\n    }\n    EXPECT_ZERO(hdfsFileGetReadStatistics(file, &readStats));\n    errno = 0;\n    EXPECT_UINT64_EQ((uint64_t)expected, readStats->totalBytesRead);\n    hdfsFileFreeReadStatistics(readStats);\n    EXPECT_ZERO(hdfsFileClearReadStatistics(file));\n    EXPECT_ZERO(hdfsFileGetReadStatistics(file, &readStats));\n    EXPECT_UINT64_EQ((uint64_t)0, readStats->totalBytesRead);\n    hdfsFileFreeReadStatistics(readStats);\n    EXPECT_ZERO(memcmp(paths->prefix, tmp, expected));\n    EXPECT_ZERO(hdfsCloseFile(fs, file));\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c#L249-L285","documentation":"Error \"hdfsRead failed and set errno %d\n\" thrown in apache/hadoop.","triggerScenarios":"Raised inside the threaded libhdfs test when hdfsRead returns -1 during concurrent read workload.","commonSituations":"Occurs in test_libhdfs_threaded when the cluster is down, the test file was not written first, or many threads race on the same file handle.","solutions":["Check errno value printed: common causes are EACCES (permissions), ENOENT (missing file), EIO (NameNode/DataNode unreachable).","Verify the HDFS path exists and the test user has read permission before calling hdfsRead.","Ensure the libhdfs client is connected to a live NameNode (check hdfsConnect succeeded earlier in the test)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}