{"record":{"id":"bd5c62af5bd52e0d","repo":"apache/hadoop","slug":"invalid-timeout-timeout-connectiontimeout-ms","errorCode":null,"errorMessage":"Invalid timeout [timeout = {connectionTimeout} ms]","messagePattern":"Invalid timeout \\[timeout = (.+?) ms\\]","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java","lineNumber":706,"sourceCode":"      url.append(mapId);\n      first = false;\n    }\n\n    if (LOG.isDebugEnabled()) {\n      LOG.debug(\"MapOutput URL for \" + host + \" -> \" + url.toString());\n    }\n    return new URL(url.toString());\n  }\n  \n  /** \n   * The connection establishment is attempted multiple times and is given up \n   * only on the last failure. Instead of connecting with a timeout of \n   * X, we try connecting with a timeout of x < X but multiple times. \n   */\n  private void connect(URLConnection connection, int connectionTimeout) throws IOException {\n    int unit = 0;\n    if (connectionTimeout < 0) {\n      throw new IOException(\"Invalid timeout \"\n                            + \"[timeout = \" + connectionTimeout + \" ms]\");\n    } else if (connectionTimeout > 0) {\n      unit = Math.min(UNIT_CONNECT_TIMEOUT, connectionTimeout);\n    }\n    long startTime = Time.monotonicNow();\n    long lastTime = startTime;\n    int attempts = 0;\n    // set the connect timeout to the unit-connect-timeout\n    connection.setConnectTimeout(unit);\n    while (true) {\n      try {\n        attempts++;\n        connection.connect();\n        break;\n      } catch (IOException ioe) {\n        long currentTime = Time.monotonicNow();\n        long retryTime = currentTime - startTime;\n        long leftTime = connectionTimeout - retryTime;","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java#L688-L724","documentation":"Fetcher.connect() slices the configured connect timeout into unit attempts (each capped at UNIT_CONNECT_TIMEOUT) and retries until the total budget is spent. A negative mapreduce.reduce.shuffle.connect.timeout cannot be sliced, so every connect attempt of the task fails immediately with this IOException.","triggerScenarios":"Job configuration sets mapreduce.reduce.shuffle.connect.timeout to a negative value, typically -1 by convention from other systems where it means 'infinite'.","commonSituations":"Copying timeout settings from other frameworks (curl, netty, postgres) where -1 disables the timeout; templates or variable substitution producing -1; misparsed integer in the job xml.","solutions":["Set mapreduce.reduce.shuffle.connect.timeout to a positive millisecond value (default 130000).","Remove the override entirely to fall back to the default.","If the intent was 'no timeout', use a large positive value such as 600000 instead of -1."],"exampleFix":"// before\nconf.setInt(\"mapreduce.reduce.shuffle.connect.timeout\", -1);\n// after\nconf.setInt(\"mapreduce.reduce.shuffle.connect.timeout\", 130000);","handlingStrategy":"validation","validationCode":"// Validate shuffle timeouts before job submission\nint connectTimeout = conf.getInt(\"mapreduce.reduce.shuffle.connect.timeout\", 130000);\nint readTimeout = conf.getInt(\"mapreduce.reduce.shuffle.read.timeout\", 80000);\nif (connectTimeout <= 0 || readTimeout <= 0) { throw new IllegalArgumentException(\"Shuffle timeouts must be positive milliseconds: connect=\" + connectTimeout + \", read=\" + readTimeout); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat -1 timeout conventions from other systems as invalid for MapReduce shuffle settings.","Add a config sanity check in job launch scripts that scans mapreduce.*.timeout keys for negative values."],"tags":["hadoop","mapreduce","shuffle","config","timeout"],"backgroundTag":"invalid-config-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}