Skip to content

Ensure empty relation file exists on disk even if nothing was exported

What does this MR do and why?

This MR updates BulkImports::RelationExportService & BulkImports::RelationBatchExportService to ensure we always export an actual file that can be downloaded, even if there were no exported records. We noticed an issue with export while debugging https://gitlab.com/gitlab-org/gitlab/-/issues/383767 is if a relation is empty and there is nothing to export we:

  • Never create a file on disk
  • Try to compress a file which does not exist
  • Resulting in 'Relation not exported' error

In this MR we create an empty file if it's not present after export. This way no changes are required on Import side and an empty relation will be marked as completed when we try to import it. As a follow up we can do a refactor by:

  • Adding is_empty flag to bulk_import_exports table
  • Ignore such export when importing, instead of downloading an empty file, saving up a few network requests

Ensure empty relation file exists on disk even if nothing was exported

Changelog: fixed

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading