iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

How Can safely delete small files after executed rewriteDataFiles

Open liuzx8888 opened this issue 3 years ago • 3 comments

Query engine

spark 3.2

Question

When I execute the rewriteDataFiles API, the small files are merged into large files. These original small files still exist in the hdfs file. The root user is the merged large file, and the flink user is the original small file.

image

trino query 'SELECT * FROM "fy_zy_fymx5$files"', the valid file is the file generated by executing the rewriteDataFiles API, the previous small file should be an invalid file image

but executed in order rewriteManifests api -->expireSnapshots api -->deleteOrphanFiles api

    //expireSnapshots
    if (operationMode.equalsIgnoreCase("expireSnapshots")) {
      val tsToExpire = System.currentTimeMillis()  
      SparkActions
        .get(spark)
        .expireSnapshots(table)
        .expireOlderThan(tsToExpire)
        .execute()
    }

    //deleteOrphanFiles
    if (operationMode.equalsIgnoreCase("deleteOrphanFiles")) {
      val olderThanTimestamp = System.currentTimeMillis
      SparkActions
        .get(spark)
        .deleteOrphanFiles(table)
        .olderThan(olderThanTimestamp)
        .prefixMismatchMode(PrefixMismatchMode.DELETE)
        .execute()
    }

    //rewriteManifests
    if (operationMode.equalsIgnoreCase("rewriteManifests")) {
      SparkActions
        .get(spark)
        .rewriteManifests(table)
        .execute()
    }

These small files still exist in hdfs and have not been deleted. How Can safely delete small files after executed rewriteDataFiles API?

liuzx8888 avatar Jul 14 '23 10:07 liuzx8888

i ran rewriteDataFiles/compaction from spark , it created big files and left small files. I ran expireSnapShot older than x hours. Then i ran deleteOrphanFiles which have cleaned up all small files and its respective manifest list & manifest files.

try compaction -> expireSnapshots -> deleteOrphanFiles.

chennurchaitanya avatar Jul 21 '23 18:07 chennurchaitanya

This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

github-actions[bot] avatar Sep 07 '24 00:09 github-actions[bot]

This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

github-actions[bot] avatar Sep 21 '24 00:09 github-actions[bot]