apache/hadoop · error

testLibHdfs: must have a number of threads between 1 and %d

Error message

testLibHdfs: must have a number of threads between 1 and %d inclusive, not %d

What it means

Error "testLibHdfs: must have a number of threads between 1 and %d inclusive, not %d " thrown in apache/hadoop.

Source

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

    const char *tlhNumThreadsStr;
    struct tlhThreadInfo ti[TLH_MAX_THREADS];
    struct NativeMiniDfsConf conf = {
        1, /* doFormat */
    };

    /* Check that the recursive mutex works as expected */
    if (testRecursiveJvmMutex() < 0) {
        fprintf(stderr, "testRecursiveJvmMutex failed\n");
        return EXIT_FAILURE;
    }

    tlhNumThreadsStr = getenv("TLH_NUM_THREADS");
    if (!tlhNumThreadsStr) {
        tlhNumThreadsStr = "3";
    }
    tlhNumThreads = atoi(tlhNumThreadsStr);
    if ((tlhNumThreads <= 0) || (tlhNumThreads > TLH_MAX_THREADS)) {
        fprintf(stderr, "testLibHdfs: must have a number of threads "
                "between 1 and %d inclusive, not %d\n",
                TLH_MAX_THREADS, tlhNumThreads);
        return EXIT_FAILURE;
    }
    memset(&ti[0], 0, sizeof(ti));
    for (i = 0; i < tlhNumThreads; i++) {
        ti[i].threadIdx = i;
    }

    tlhCluster = nmdCreate(&conf);
    EXPECT_NONNULL(tlhCluster);
    EXPECT_ZERO(nmdWaitClusterUp(tlhCluster));

    for (i = 0; i < tlhNumThreads; i++) {
        ti[i].theThread.start = testHdfsOperations;
        ti[i].theThread.arg = &ti[i];
        EXPECT_ZERO(threadCreate(&ti[i].theThread));
    }

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a thread count between 1 and the printed maximum via the -t option.
  2. Use a positive thread count; 0 or negative values are rejected.
  3. Do not exceed the compiled-in maximum thread count shown in the message.

When it happens

Trigger: Argument validation in testLibHdfs main: the -t thread count is outside [1, TLH_MAX_THREADS].

Common situations: User ran the test binary with an out-of-range -t value, e.g. -t 0 or a value larger than the maximum supported.


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