prestodb/presto · error · PrestoException

HIVE_FILESYSTEM_ERROR

HIVE_FILESYSTEM_ERROR

Error message

Error deleting from unpartitioned table %s. These items can not be deleted: %s

What it means

During truncation, recursiveDeleteFiles may leave eligible items undeleted (e.g. permission problems, concurrent writers, transient HDFS/S3 errors). If the NotDeletedEligibleItems set is non-empty, the metastore throws PrestoException(HIVE_FILESYSTEM_ERROR) naming the table and the undeleted items, since the delete cannot be guaranteed complete.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:618

                databaseName,
                tableName);
        SchemaTableName schemaTableName = new SchemaTableName(databaseName, tableName);
        if (!table.isPresent()) {
            throw new TableNotFoundException(schemaTableName);
        }
        if (!table.get().getTableType().equals(MANAGED_TABLE) && !table.get().getTableType().equals(MATERIALIZED_VIEW)) {
            throw new PrestoException(NOT_SUPPORTED, "Cannot delete from non-managed Hive table");
        }
        if (!table.get().getPartitionColumns().isEmpty()) {
            throw new IllegalArgumentException("Table is partitioned");
        }

        Path path = new Path(table.get().getStorage().getLocation());
        HdfsContext context = new HdfsContext(session, databaseName, tableName, table.get().getStorage().getLocation(), false);
        setExclusive((delegate, hdfsEnvironment) -> {
            RecursiveDeleteResult recursiveDeleteResult = recursiveDeleteFiles(hdfsEnvironment, context, path, ImmutableSet.of(""), false);
            if (!recursiveDeleteResult.getNotDeletedEligibleItems().isEmpty()) {
                throw new PrestoException(HIVE_FILESYSTEM_ERROR, format(
                        "Error deleting from unpartitioned table %s. These items can not be deleted: %s",
                        schemaTableName,
                        recursiveDeleteResult.getNotDeletedEligibleItems()));
            }
            return EMPTY_HIVE_COMMIT_HANDLE;
        });
    }

    public Optional<List<PartitionNameWithVersion>> getPartitionNames(MetastoreContext metastoreContext, String databaseName, String tableName)
    {
        HiveTableHandle hiveTableHandle = new HiveTableHandle(databaseName, tableName);
        return getPartitionNames(metastoreContext, hiveTableHandle);
    }

    public synchronized Optional<List<PartitionNameWithVersion>> getPartitionNames(MetastoreContext metastoreContext, HiveTableHandle hiveTableHandle)
    {
        return doGetPartitionNames(metastoreContext, hiveTableHandle, ImmutableMap.of());
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fix filesystem permissions so the Presto user can delete all files under the table location
  2. Ensure no concurrent writers; stop ingestion jobs before deleting from the table
  3. Retry the DELETE after resolving transient object-store/HDFS issues
  4. Inspect the listed not-deleted items and remove them manually, then re-run

Example fix

// before (shell)
DELETE FROM t; // HIVE_FILESYSTEM_ERROR: items can not be deleted
// after (shell)
hdfs dfs -chmod -R u+rwx /warehouse/t/  # or fix S3 bucket policy
-- then retry
DELETE FROM t;
Defensive patterns

Strategy: retry

Validate before calling

// pre-check write access to table location
if (!fsAccess.canDelete(new Path(table.getStorage().getLocation()))) {
    throw new IllegalStateException("Presto user lacks delete permission on table location");
}

Try / catch

try {
    metastore.truncateUnpartitionedTable(session, db, tbl);
} catch (PrestoException e) {
    if (e.getErrorCode() == HIVE_FILESYSTEM_ERROR.toErrorCode() && attempt < MAX) {
        backoffAndRetry();
    } else throw e;
}

Prevention

When it happens

Trigger: truncateUnpartitionedTable on a table whose location contains files that cannot be deleted: insufficient HDFS/S3 permissions, files locked or being written concurrently, quota or consistency issues.

Common situations: External writers still committing files during DELETE; misconfigured filesystem permissions for the Presto service user; eventual-consistency lag on object stores; read-only mounts.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/5abe7bd167ef04a4. Report an issue: GitHub.