apache/iceberg · warning

Failed to close task iterable

Error message

Failed to close task iterable

What it means

SparkTable.canDeleteUsingMetadata evaluates whether a DELETE can be satisfied by metadata only (dropping whole files). While closing the task's CloseableIterable, an IOException occurred; the method logs it and returns false, so the delete falls back to a rewrite (copy-on-write) plan. Correctness is preserved, only efficiency is lost.

Solutions

  1. No action required — delete falls back to copy-on-write and still succeeds.
  2. Check storage connectivity/permissions if the warning recurs.
  3. If metadata-only deletes matter for performance, resolve the underlying IO error so planning completes.
Defensive patterns

Strategy: fallback

Try / catch

// deleteWhere still succeeds via CoW fallback; retry the DELETE if metadata-only behavior is required

Prevention

When it happens

Trigger: During metadata-only delete planning, closing the per-task iterable (e.g. after reading file partitions/metrics) throws IOException, caught at the end of canDeleteUsingMetadata.

Common situations: Underlying storage hiccup while closing manifest/task streams; credentials or network issues mid-planning; Hadoop FileSystem deprecation warnings surfacing as IO errors on close.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/64bf0b4efb677b81. Report an issue: GitHub.

Appendix: source

Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java:444

      StrictMetricsEvaluator metricsEvaluator =
          new StrictMetricsEvaluator(SnapshotUtil.schemaFor(table(), scanBranch), deleteExpr);

      return Iterables.all(
          tasks,
          task -> {
            DataFile file = task.file();
            PartitionSpec spec = task.spec();
            Evaluator evaluator =
                evaluators.computeIfAbsent(
                    spec.specId(),
                    specId ->
                        new Evaluator(
                            spec.partitionType(), Projections.strict(spec).project(deleteExpr)));
            return evaluator.eval(file.partition()) || metricsEvaluator.eval(file);
          });

    } catch (IOException ioe) {
      LOG.warn("Failed to close task iterable", ioe);
      return false;
    }
  }

  @Override
  public void deleteWhere(Predicate[] predicates) {
    Expression deleteExpr = SparkV2Filters.convert(predicates);

    if (deleteExpr == Expressions.alwaysFalse()) {
      LOG.info("Skipping the delete operation as the condition is always false");
      return;
    }

    DeleteFiles deleteFiles =
        icebergTable
            .newDelete()
            .set("spark.app.id", sparkSession().sparkContext().applicationId())
            .deleteFromRowFilter(deleteExpr);

View on GitHub (pinned to 86d9c8fc54)