<@U04S8PLJWMT> Warning from destination: Already c...
# ask-ai
a
@kapa.ai Warning from destination: Already closed files for partition: created_at_day=2025-05-05 how to solve this error?
k
That warning typically means the destination is trying to write again into a partition/file that has already been finalized (closed) for that run, often because of how overwrite/truncate logic or multiple concurrent syncs interact with object-storage destinations. From the provided knowledge: - Running truncate/overwrite-like behaviors together with other file operations can delete or invalidate files that are still in use. For S3/GCS data lake destinations, you must not run compaction or other cleanup while a truncate refresh sync is running, or you risk deleting or “closing” files from the current generation and then trying to write to them again, which causes errors or data loss.[[S3 compaction](https://docs.airbyte.com/integrations/destinations/s3-data-lake#compaction); [GCS compaction](https://docs.airbyte.com/integrations/destinations/gcs-data-lake#compaction)] - Using multiple connections that share the same bucket/path can also cause one job to clean up or overwrite files that another job is still using. This was seen with S3 where one connection’s cleanup removed files from another long‑running connection, causing it to “start from the beginning” and run into key/file issues.[[S3 key cleanup](https://discuss.airbyte.io/t/1489)] - In overwrite/“truncate” scenarios, current implementations may delete everything under the stream’s prefix (e.g.
namespace/stream/
), not just a single partition, so subsequent writes to specific partitions can be impacted if multiple runs overlap or share the same path.[[Partition overwrite](https://github.com/airbytehq/airbyte/issues/23981)] Given that, the concrete mitigations are: 1. Avoid concurrent jobs sharing the same destination path - Do not run two connections at the same time that write to the same bucket/prefix (e.g. same S3 or GCS path). If you must share a bucket, give each connection a unique prefix. 2. Do not run compaction or external cleanup during a truncate/overwrite sync - If you use S3/GCS Data Lake compaction or any custom cleanup scripts, schedule them so they never overlap with truncate/overwrite runs.[[S3 compaction](https://docs.airbyte.com/integrations/destinations/s3-data-lake#compaction); [GCS compaction](https://docs.airbyte.com/integrations/destinations/gcs-data-lake#compaction)] 3. Check your sync mode and path pattern - If you’re using Overwrite/Truncate with date‑partitioned paths (e.g.
.../created_at_day=YYYY‑MM‑DD/
), be aware that Airbyte may delete the entire stream prefix each run, not just one partition.[[Partition overwrite](https://github.com/airbytehq/airbyte/issues/23981)] - If that’s impacting you, consider: - Using Append mode plus an external process to manage partition clean‑up, or - Isolating each partition or job into its own prefix so deletes don’t collide. Because the exact destination connector isn’t stated in your question and the knowledge sources don’t contain that exact warning string, I can’t point to a more specific fix. If you share: - The destination type (S3, GCS, S3 Data Lake, GCS Data Lake, etc.), - The sync mode, and - Whether multiple connections share the same bucket/path, it may be possible to narrow this down further within the documented behaviors above.
a
@kapa.ai the destination type is S3 Data Lake and no two connectors share the same destination
k
A message from kapa.ai
For S3 Data Lake, a partition warning like: >
Already closed files for partition: created_at_day=2025-05-05
means the connector thinks it has already finalized the files belonging to that Iceberg partition during the current sync (the partition is “closed”), but something is trying to write/flush to it again. From the available docs, the main S3 Data Lake behaviors to check are: 1. Truncate (overwrite) semantics and generations In truncate-style syncs, the connector writes to a staging branch and then replaces the
main
branch at the end of the sync. Any changes to
main
outside Airbyte after the sync starts are lost when branches are swapped.[[Branching](https://docs.airbyte.com/integrations/destinations/s3-data-lake#branching-and-data-availability)] If you have any external writers (or processes) touching the same Iceberg table/branch during the sync, that can interfere with what the connector considers “closed” partitions. 2. Compaction and file deletion during sync The docs explicitly warn not to run compaction during a truncate refresh sync, because the system will delete files that don’t belong to the latest generation (including files without generation IDs and files from previous generations). If compaction runs at the same time as the sync, it can delete files from the current generation and cause inconsistent file/partition state.[[Compaction](https://docs.airbyte.com/integrations/destinations/s3-data-lake#compaction)] This can lead to situations where the connector has logically closed a partition but physical files are missing or inconsistent. 3. Connector’s own catalog/cleanup logic The S3 Data Lake connector runs catalog checks and table clean‑up (via
IcebergTableCleaner.clearTable
and GlueCatalog operations) as part of its validation and possibly truncate behavior.[[S3 Data Lake stacktrace](https://github.com/airbytehq/airbyte/issues/69087)] If that cleanup drops or rewrites table data while a partition was already closed in memory, subsequent writes to that partition during the same run could trigger warnings like the one you see. Given that you: - Use S3 Data Lake, and - Confirm no two connections share the same destination, the most concrete actions based on the docs are: 1. Verify that no external process is modifying or compacting the same Iceberg table during the sync - Disable any scheduled compaction or table rewrite jobs (Spark, Flink, engine‑specific “optimize/compact” commands) that could touch these S3 paths while Airbyte runs.[[Compaction](https://docs.airbyte.com/integrations/destinations/s3-data-lake#compaction)] - Ensure only Airbyte writes to the
main
and
airbyte_staging
branches during the sync.[[Branching](https://docs.airbyte.com/integrations/destinations/s3-data-lake#branching-and-data-availability)] 2. Avoid manual deletes in the S3 prefix during runs Manual S3 cleanup done mid‑sync could put the connector in a state where it has “closed” a partition but the underlying files are no longer in the expected layout. 3. Check whether the warning is accompanied by hard failures The knowledge sources do not mention this exact warning string or a specific documented fix; they only describe the deletion/compaction and branching behavior. If your sync still completes successfully, the warning may indicate an internal guard that prevented double‑writing to a partition after it was closed, but this is not documented explicitly. Because none of the provided sources refer directly to the message “Already closed files for partition”, I cannot point to an official, named bug or configuration flag that resolves it. The only documented mitigations are around not running compaction or external changes during truncate refresh syncs and relying solely on Airbyte to manage the table during the run.[[Branching](https://docs.airbyte.com/integrations/destinations/s3-data-lake#branching-and-data-availability); [Compaction](https://docs.airbyte.com/integrations/destinations/s3-data-lake#compaction)] If you still see the warning with: - No compaction jobs, - No external writers, and - Only a single Airbyte connection pointing at that table, then the knowledge sources do not contain further guidance, and you may need to open or update a GitHub issue with logs for the S3 Data Lake connector.