Problem/Motivation

On certain setups, notably Acquia production environments, several containers might be serving one application, and a load balancer will determine which container serves each request.

The public files directory is always shared between containers, but the /tmp directory is not. For example, this StackOverflow question states that on Kubernetes setups, it is not good practice to share /tmp directories between containers.

CSV uses a progress bar which requires multiple web requests to the server, and each web request can potentially use a different container, hence a different /tmp directory, leading to errors such as "file cannot be uploaded".

This is exactly the same problem that the Webform module solved in #2980276: Webform assumes the /tmp directory is always the same, but if there are multiple servers, each may have its own /tmp directory and may be related to #3129972: Error file upload.

One workaround is to

  • create a temporary folder in the public file directory, such as /path/to/public/files/02b25f9f-53e2-43ce-a383-3a7285153c77 (I use a random UUID to make it harder for someone to stumble on my data)
  • add $settings['file_temp_path'] = '/path/to/public/files/02b25f9f-53e2-43ce-a383-3a7285153c77'; to your settings file
  • perform your import
  • Remove the $settings['file_temp_path'] line from settings.php and remove the /path/to/public/files/02b25f9f-53e2-43ce-a383-3a7285153c77 directory

Steps to reproduce

Create a Kubernetes Drupal setup with more than one container serving Drupal, the run an import from the GUI.

Proposed resolution

Do not assume that a file which exists in /tmp/xyz.csv on one web request will also exist on the next web request. On every request during the progress of an import, check if /tmp/xyz.csv exists, and if it does, give an error message which links back to this issue.

You can also look at how Webform resolved this in #2980276: Webform assumes the /tmp directory is always the same, but if there are multiple servers, each may have its own /tmp directory

Remaining tasks

To be determined.

User interface changes

To be determined.

API changes

To be determined.

Data model changes

None.

Comments

alberto56 created an issue.