{"record":{"id":"5abe7bd167ef04a4","repo":"prestodb/presto","slug":"hive-filesystem-error-5abe7b","errorCode":"HIVE_FILESYSTEM_ERROR","errorMessage":"Error deleting from unpartitioned table %s. These items can not be deleted: %s","messagePattern":"Error deleting from unpartitioned table (.+?)\\. These items can not be deleted: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java","lineNumber":618,"sourceCode":"                databaseName,\n                tableName);\n        SchemaTableName schemaTableName = new SchemaTableName(databaseName, tableName);\n        if (!table.isPresent()) {\n            throw new TableNotFoundException(schemaTableName);\n        }\n        if (!table.get().getTableType().equals(MANAGED_TABLE) && !table.get().getTableType().equals(MATERIALIZED_VIEW)) {\n            throw new PrestoException(NOT_SUPPORTED, \"Cannot delete from non-managed Hive table\");\n        }\n        if (!table.get().getPartitionColumns().isEmpty()) {\n            throw new IllegalArgumentException(\"Table is partitioned\");\n        }\n\n        Path path = new Path(table.get().getStorage().getLocation());\n        HdfsContext context = new HdfsContext(session, databaseName, tableName, table.get().getStorage().getLocation(), false);\n        setExclusive((delegate, hdfsEnvironment) -> {\n            RecursiveDeleteResult recursiveDeleteResult = recursiveDeleteFiles(hdfsEnvironment, context, path, ImmutableSet.of(\"\"), false);\n            if (!recursiveDeleteResult.getNotDeletedEligibleItems().isEmpty()) {\n                throw new PrestoException(HIVE_FILESYSTEM_ERROR, format(\n                        \"Error deleting from unpartitioned table %s. These items can not be deleted: %s\",\n                        schemaTableName,\n                        recursiveDeleteResult.getNotDeletedEligibleItems()));\n            }\n            return EMPTY_HIVE_COMMIT_HANDLE;\n        });\n    }\n\n    public Optional<List<PartitionNameWithVersion>> getPartitionNames(MetastoreContext metastoreContext, String databaseName, String tableName)\n    {\n        HiveTableHandle hiveTableHandle = new HiveTableHandle(databaseName, tableName);\n        return getPartitionNames(metastoreContext, hiveTableHandle);\n    }\n\n    public synchronized Optional<List<PartitionNameWithVersion>> getPartitionNames(MetastoreContext metastoreContext, HiveTableHandle hiveTableHandle)\n    {\n        return doGetPartitionNames(metastoreContext, hiveTableHandle, ImmutableMap.of());\n    }","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java#L600-L636","documentation":"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.","triggerScenarios":"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.","commonSituations":"External writers still committing files during DELETE; misconfigured filesystem permissions for the Presto service user; eventual-consistency lag on object stores; read-only mounts.","solutions":["Fix filesystem permissions so the Presto user can delete all files under the table location","Ensure no concurrent writers; stop ingestion jobs before deleting from the table","Retry the DELETE after resolving transient object-store/HDFS issues","Inspect the listed not-deleted items and remove them manually, then re-run"],"exampleFix":"// before (shell)\nDELETE FROM t; // HIVE_FILESYSTEM_ERROR: items can not be deleted\n// after (shell)\nhdfs dfs -chmod -R u+rwx /warehouse/t/  # or fix S3 bucket policy\n-- then retry\nDELETE FROM t;","handlingStrategy":"retry","validationCode":"// pre-check write access to table location\nif (!fsAccess.canDelete(new Path(table.getStorage().getLocation()))) {\n    throw new IllegalStateException(\"Presto user lacks delete permission on table location\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    metastore.truncateUnpartitionedTable(session, db, tbl);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == HIVE_FILESYSTEM_ERROR.toErrorCode() && attempt < MAX) {\n        backoffAndRetry();\n    } else throw e;\n}","preventionTips":["Quiesce concurrent writers before DELETE","Grant the Presto service user delete permissions on warehouse paths","Monitor object-store/HDFS health; retry transient failures"],"tags":["hive","filesystem","hdfs","s3","delete"],"backgroundTag":"filesystem-delete-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}