{"record":{"id":"b7d173bef43013a5","repo":"apache/hadoop","slug":"lease-desired-but-no-lease-threads-configured-set","errorCode":null,"errorMessage":"Lease desired but no lease threads configured, set fs.azure.lease.threads","messagePattern":"Lease desired but no lease threads configured, set fs\\.azure\\.lease\\.threads","errorType":"validation","errorClass":"LeaseException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsLease.java","lineNumber":137,"sourceCode":"   * @param eTag                ETag of the file\n   * @param tracingContext      Tracing context\n   * @throws AzureBlobFileSystemException if the lease cannot be acquired\n   */\n  @VisibleForTesting\n  public AbfsLease(AbfsClient client, String path, final boolean isAsync, int acquireMaxRetries,\n                   int acquireRetryInterval, final long leaseRefreshDuration,\n                   final String eTag,\n                   TracingContext tracingContext) throws AzureBlobFileSystemException {\n    this.leaseFreed = false;\n    this.client = client;\n    this.path = path;\n    this.tracingContext = tracingContext;\n    this.leaseRefreshDuration = leaseRefreshDuration;\n    this.leaseRefreshDurationInSeconds = (int) leaseRefreshDuration / ONE_THOUSAND;\n    this.isAsync = isAsync;\n\n    if (isAsync && client.getNumLeaseThreads() < 1) {\n      throw new LeaseException(ERR_NO_LEASE_THREADS);\n    }\n\n    // Try to get the lease a specified number of times, else throw an error\n    RetryPolicy retryPolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(\n        acquireMaxRetries, acquireRetryInterval, TimeUnit.SECONDS);\n    this.timer = new Timer(\n            String.format(\"lease-refresh-timer-%s\", path), true);\n    acquireLease(retryPolicy, 0, acquireRetryInterval, 0, eTag,\n        new TracingContext(tracingContext));\n\n    while (leaseID == null && exception == null) {\n      try {\n        future.get();\n      } catch (Exception e) {\n        LOG.debug(\"Got exception waiting for acquire lease future. Checking if lease ID or \"\n            + \"exception have been set\", e);\n      }\n    }","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsLease.java#L119-L155","documentation":"The AbfsLease constructor throws LeaseException(\"Lease desired but no lease threads configured, set fs.azure.lease.threads\") when an asynchronous lease is requested (isAsync) and AbfsClient.getNumLeaseThreads() < 1. The lease scheduler pool is sized by fs.azure.lease.threads, whose default is 0 (FileSystemConfigurations.DEFAULT_LEASE_THREADS = 0), so async leasing is opt-in: it fails fast at lease creation rather than deadlocking later.","triggerScenarios":"Code path acquiring an async lease (lease-class output streams on leased files) while fs.azure.lease.threads is unset or 0 in core-site.xml / the abfs mount config; configs copied from templates that omit lease keys; setting the value to 0 explicitly to 'disable' the pool while still using async leases.","commonSituations":"Enabling fs.azure lease features (fs.azure.lease.*) without sizing the thread pool; environment-specific configs (test/dev) missing keys that prod has; upgrading hadoop-azure to a version where the async-lease path became the default for leased writes.","solutions":["Set fs.azure.lease.threads to at least 1 (e.g., 4) wherever async leases are used","If you do not need async leases, disable the lease feature rather than leaving threads at 0","Verify with conf.getInt(\"fs.azure.lease.threads\", 0) before initializing the filesystem"],"exampleFix":"<!-- before: missing / zero threads -->\n<property>\n  <name>fs.azure.lease.threads</name>\n  <value>0</value>\n</property>\n\n<!-- after -->\n<property>\n  <name>fs.azure.lease.threads</name>\n  <value>4</value>\n</property>","handlingStrategy":"validation","validationCode":"// Fail fast on bad lease config before creating the filesystem\nint leaseThreads = conf.getInt(\"fs.azure.lease.threads\", 0);\nif (usingAsyncLeases && leaseThreads < 1) {\n  throw new IllegalArgumentException(\n      \"fs.azure.lease.threads must be >= 1 when async leases are used (was \"\n      + leaseThreads + \")\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set fs.azure.lease.threads >= 1 in every environment that enables ABFS leases","Validate lease-related keys in a config smoke test before deploying","Remember the default is 0 — omitting the key is itself a misconfiguration"],"tags":["azure-blob","abfs","lease","configuration","thread-pool","hadoop"],"backgroundTag":"invalid-configuration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}