{"record":{"id":"8dd6a6bc48c11294","repo":"apache/hadoop","slug":"clock-gettime-clock-monotonic-failed-with-error","errorCode":null,"errorMessage":"clock_gettime(CLOCK_MONOTONIC) failed with error %d (%s)\n","messagePattern":"clock_gettime\\(CLOCK_MONOTONIC\\) failed with error (.+?) \\((.+?)\\)\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":92,"sourceCode":"}\n#else\nstatic int clock_gettime_mono(struct timespec * ts) {\n    return clock_gettime(CLOCK_MONOTONIC, ts);\n}\n#endif\n\nstatic struct stopwatch *stopwatch_create(void)\n{\n    struct stopwatch *watch;\n\n    watch = calloc(1, sizeof(struct stopwatch));\n    if (!watch) {\n        fprintf(stderr, \"failed to allocate memory for stopwatch\\n\");\n        goto error;\n    }\n    if (clock_gettime_mono(&watch->start)) {\n        int err = errno;\n        fprintf(stderr, \"clock_gettime(CLOCK_MONOTONIC) failed with \"\n            \"error %d (%s)\\n\", err, strerror(err));\n        goto error;\n    }\n    return watch;\n\nerror:\n    free(watch);\n    return NULL;\n}\n\nstatic void stopwatch_stop(struct stopwatch *watch,\n        long long bytes_read)\n{\n    double elapsed, rate;\n\n    if (clock_gettime_mono(&watch->stop)) {\n        int err = errno;\n        fprintf(stderr, \"clock_gettime(CLOCK_MONOTONIC) failed with \"","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c#L74-L110","documentation":"Error \"clock_gettime(CLOCK_MONOTONIC) failed with error %d (%s)\n\" thrown in apache/hadoop.","triggerScenarios":"clock_gettime(CLOCK_MONOTONIC) returned an error while taking benchmark timestamps in vecsum.","commonSituations":"Non-POSIX or stripped-down environment lacking monotonic clock support, or missing librt linkage on old systems.","solutions":["Run on a platform where CLOCK_MONOTONIC is supported (POSIX.1-2001+); on Linux this should always work.","Check errno printed: if EPERM/EINVAL, verify the clock id and that the kernel supports monotonic clocks.","Link with -lrt on older glibc systems where clock_gettime lives in librt."],"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-23T01:17:44.959Z"}