Indian-boult opened a new issue, #1021: URL: https://github.com/apache/incubator-xtable/issues/1021
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-xtable/issues?q=is%3Aissue) and found no similar issues. ### Please describe the bug 🐞 When the Iceberg target is written into a Delta table's directory, which is XTable's default layout, Delta `VACUUM` deletes Iceberg metadata files that the current Iceberg snapshot still references. The Iceberg table then fails to read. `VACUUM` removes every file in the table directory that the Delta log does not track and that is older than the retention period (7 days by default). It skips only directories whose names start with `_` or `.`. Delta skips Iceberg's `metadata/` directory only when the Delta table itself has UniForm Iceberg enabled: `shouldIcebergMetadataDirBeHidden = UniversalFormat.icebergEnabled(snapshot.metadata)` in `VacuumCommand.scala` (line 275 in v3.3.0, line 289 in v4.0.0). A table synced by XTable does not enable UniForm, so its `metadata/` directory is not skipped. Iceberg keeps reusing manifests from earlier commits as long as their data files are still live. So a manifest written by the first sync can still be in use weeks later. Once it is older than the Delta retention, `VACUUM` deletes it. Repro on main (`e91662f`) with Spark 3.4.2, Delta 2.4.0 and Iceberg 1.9.2: 1. Create a Delta table and insert rows. Sync it to Iceberg with `ConversionController` into the same base path. 2. Make the first sync's Iceberg files older than the retention. The test sets their modification time back 30 days. 3. Insert more rows and run an incremental sync. The current Iceberg snapshot still lists the first manifest. 4. Run `VACUUM <table>` with the default retention. `VACUUM ... DRY RUN` lists five Iceberg files: `v1` to `v3.metadata.json`, the first manifest list and its manifest. After `VACUUM`, reading the Iceberg table fails with `org.apache.iceberg.exceptions.NotFoundException: ... -m0.avro`. Expected behavior: a routine Delta `VACUUM` does not break the Iceberg table that XTable maintains next to it. I am not sure of the right fix and would like a maintainer's view. Some options: - Document the problem, and ask users to exclude the Iceberg metadata from `VACUUM` some other way. - Write the Iceberg metadata under a directory that `VACUUM` skips, such as one whose name starts with `_`, where the catalog allows it (`write.metadata.path`). `HadoopTables` always uses `<location>/metadata`. - Warn when the Delta source is synced to an Iceberg target in the same directory. This came up while looking at #339. Deletion vector delete files written into the table directory would hit the same rule, so they would need a directory whose name starts with `_`. ### Are you willing to submit PR? - [X] I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
