apache/hadoop · error

clock_gettime(CLOCK_MONOTONIC) failed with error %d (%s)

Error message

clock_gettime(CLOCK_MONOTONIC) failed with error %d (%s)

What it means

Error "clock_gettime(CLOCK_MONOTONIC) failed with error %d (%s) " thrown in apache/hadoop.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c:92

}
#else
static int clock_gettime_mono(struct timespec * ts) {
    return clock_gettime(CLOCK_MONOTONIC, ts);
}
#endif

static struct stopwatch *stopwatch_create(void)
{
    struct stopwatch *watch;

    watch = calloc(1, sizeof(struct stopwatch));
    if (!watch) {
        fprintf(stderr, "failed to allocate memory for stopwatch\n");
        goto error;
    }
    if (clock_gettime_mono(&watch->start)) {
        int err = errno;
        fprintf(stderr, "clock_gettime(CLOCK_MONOTONIC) failed with "
            "error %d (%s)\n", err, strerror(err));
        goto error;
    }
    return watch;

error:
    free(watch);
    return NULL;
}

static void stopwatch_stop(struct stopwatch *watch,
        long long bytes_read)
{
    double elapsed, rate;

    if (clock_gettime_mono(&watch->stop)) {
        int err = errno;
        fprintf(stderr, "clock_gettime(CLOCK_MONOTONIC) failed with "

View on GitHub (pinned to 2add963021)

Solutions

  1. Run on a platform where CLOCK_MONOTONIC is supported (POSIX.1-2001+); on Linux this should always work.
  2. Check errno printed: if EPERM/EINVAL, verify the clock id and that the kernel supports monotonic clocks.
  3. Link with -lrt on older glibc systems where clock_gettime lives in librt.

When it happens

Trigger: clock_gettime(CLOCK_MONOTONIC) returned an error while taking benchmark timestamps in vecsum.

Common situations: Non-POSIX or stripped-down environment lacking monotonic clock support, or missing librt linkage on old systems.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/8dd6a6bc48c11294. Report an issue: GitHub.