Closed (fixed)
Project:
Webform
Version:
8.x-5.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2018 at 16:49 UTC
Updated:
13 Sep 2022 at 16:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jrockowitz commentedHave you checked your error log? (/admin/reports/dblog)
Comment #3
alberto56 commentedNothing gets logged to the watchdog. Is there a "debug" mode I can use?
I do have a bit more info about this one.
* I have 1038 total submissions for the month of May.
* I have downloaded the submissions as CSV files several times, and the resulting file is always slightly different; it never actually has 1038 submissions though, it seems to get stuck once in a while.
As you can see above, the result is inconsistent. It's not clear how to actually consistently download the exact number of submissions and have the same results every time.
Comment #4
alberto56 commentedSome more information on this:
* Using a database dump from production but developing locally, this works fine.
* On Acquia cloud, this breaks, however no error message is logged.
Comment #5
alberto56 commentedComment #6
jrockowitz commentedMy best guess is that you are running out of memory.
Try decreasing the batch size (/admin/structure/webform/config/advanced).
Comment #7
alberto56 commentedThanks,
I reduced the batch size from 500 to 100 and I'm still getting the problem on Acquia cloud production (not staging). And no PHP errors.
I then set the batch size to 1, and the problem is still occurring.
I am having the same problem with Safari and Chrome.
I have opened a ticket with Acquia (number 702279) to see if they have input. I'll leave at "Postpone" until I get an answer from Acquia.
Comment #8
jrockowitz commentedThe next guess is that a specific submission is causing a fatal error.
If you can export and attach your webform without any email addresses. I might be able to replicate the issue.
Comment #9
alberto56 commentedI tried this with two completely different forms and the problem always occurs, so this is not lined to one submission.
I cannot yet replicate it myself, this only happens on my production Acquia environment, no other environment is affected. If I manage to replicate it locally, I will package a sanitized version of the database.
Here is an interesting fact about this bug:
On my production environment where this bug occurs, on Safari on Mac, downloading an export several times in a row causes exports with different sizes, but with names which include an incremented number, as follows.
On my stage environment where this bug does not occur, on Safari on Mac, downloading an export several times in a row results in there being exactly one download (which has the right number of rows): it seems that the system does not attempt to save a second version of the export if an existing version has been saved. So, no matter how many times I run the export, I get:
Comment #10
jrockowitz commentedSome more guesses...
Could be a special character in a submission?
Could be a database issue?
Could be an issue with Acquia's temp directory not deleting the file?
Comment #11
alberto56 commentedThanks @jrockowitz
I have confirmed that there is no special character in submissions or database issue, as an exact clone of the failing database works on another environment.
However, I will look into the /tmp directory issue, thanks for that idea!
Here is another interesting fact:
On an environment that works, I can download 972 submissions, and end up with a file with 973 lines (which is expected):
$ wc -l ~/Downloads/*.csv
973 /Users/albert/Downloads/webform_50386.csv
On an environment which does not work, if you download the same file often enough, you can end up with a file having number of lines which is _higher_ than actual number of submissions, in this case webform_50386-9.csv has 1032 lines but there are only a total of 972 submissions:
$ wc -l ~/Downloads/*.csv
442 /Users/albert/Downloads/webform_50386-2.csv
125 /Users/albert/Downloads/webform_50386-3.csv
809 /Users/albert/Downloads/webform_50386-4.csv
948 /Users/albert/Downloads/webform_50386-5.csv
402 /Users/albert/Downloads/webform_50386-6.csv
520 /Users/albert/Downloads/webform_50386-7.csv
361 /Users/albert/Downloads/webform_50386-8.csv
1032 /Users/albert/Downloads/webform_50386-9.csv
168 /Users/albert/Downloads/webform_50386.csv
973 /Users/albert/Downloads/uncorrupted-data-webform_50386.csv
5780 total
In this case the corrupted /Users/albert/Downloads/webform_50386-9.csv has _more_ lines than /Users/albert/Downloads/uncorrupted-data-webform_50386.csv, which is the uncorrupted export.
I checked the diff between the corrupted and uncorrupted exports, and it turns out several records are missing in the corrupted export, and other records are duplicated, which accounts for the fact that the corrupted file is larger than the uncorrupted file.
Comment #12
alberto56 commentedHere are the contents of my /tmp directory on Acquia:
On the broken environment:
On the working environment:
(it is empty)
I deleted all webform_* files (which were all old files from an old Drupal 7 environment) from the /tmp directory in the broken environment, and, still, getting the same behaviour.
Comment #13
alberto56 commentedHere is some more information on this: Acquia seems to store different production sites on the same servers, so I have another site I manage, this one a Drupal 7 site, on the same production server as the affected Drupal 8 site.
I also have Webform D7 on that site, and I am experiencing similar behavior when downloading exported Webform Submissions: downloading a submission on the Drupal 7 on that server systematically results in zero-byte downloads, but on the staging environment of that Drupal 7 site everything works as expected.
I am still waiting for a response from Acquia on this and will update this issue accordingly.
Comment #14
jrockowitz commentedIt sounds like Acquia is having issues with the tmp file directory.
I would expect if you deleted all the webform_* temp files and created a new export it should work.
The \Drupal\webform\Controller\WebformResultsExportController::downloadFile method deletes the temp CSV. You might want to comment out
$response->deleteFileAfterSend(TRUE);and see what is left the /tmp directory.BTW, have tried using the
drush webform-exportcommand.Comment #15
alberto56 commented@jrockowitz thanks to your help, I have found the issue:
is exactly right. Changing the /tmp directory to something else completely fixed this issue.
Here is how I found this:
drush webform-export worked perfectly. However, deleting "webform_*" files from the /tmp directory did not fix the issue.
I then changed the \Drupal\webform\Controller\WebformResultsExportController::downloadFile to this:
just to see what happens.
With that code in place, I deleted everything in my /tmp folder and my downloads folder, then exported a webform with 972 submissions, then I performed a download a first time.
This created a file with 801 lines in my /tmp folder:
I can then repeatedly download this file by clicking "Download the file here" (because it is not deleted after it is downloaded, as per my above changes).
The result is all over the map:
This told me that, definitely there is a problem with /tmp folder.
Because this issue has nothing to do with Webform, I'll close it.
Thanks again for your kind assistance!
Comment #16
alberto56 commentedComment #17
jrockowitz commented@alberto56 What version of PHP are you running on Acquia?
Comment #18
jrockowitz commentedI think you need to change your temp directory.
@see https://docs.acquia.com/en/stable/acquia-cloud/manage/files/broken/
Comment #19
alberto56 commentedThanks for the resource. I'm using php 7.2. And, yes, changing the /tmp directory makes everything work perfectly!
Comment #20
alberto56 commentedIn fact #2221651: Make temporary export file path configurable is the exact issue I am having.
Comment #21
alberto56 commentedThis got me thinking: as a lot of webservers are moving toward multi-node setups, multiple containers such as Kubernetes, and so on, might it benefit Webform to no longer assume that /tmp is always accessible and the same between requests? See also https://stackoverflow.com/questions/50955591
Comment #22
alberto56 commentedComment #23
jrockowitz commentedI can't see having webform write temp files to the /sites/files directory. If the files directory is being replicated it would create performance issues during the batch export. My main client's load balancers keeps a returning user on the same server.
Acquia's connector should add a warning to Drupal's status report.
Comment #24
alberto56 commentedHi, Acquia has gotten back to me, suggesting I use the technique at #2221651: Make temporary export file path configurable. On this page, they say:
However, that functionality seems to have been removed in commit c938264 of Webform:
I informed Acquia of your suggestion to always direct same-source traffic to the same server, however my understanding is that as of right now all Acquia "enterprise" users having more than one webserver will be unable to export any submission data.
Comment #25
jrockowitz commentedHere is my first attempt at a patch.
Comment #26
jrockowitz commentedThe attached patch adds directory validation and configuration to the custom temp directory.
Comment #27
jrockowitz commentedComment #28
alberto56 commentedThanks, much appreciated!
Applying this patch and running drush updb -y works fine.
Changing the settings via the GUI at /admin/structure/webform/config/exporters and exporting the settings yields:
(I'm not sure why it's removing "file_name" here... maybe that's unrelated?)
However I ran into the following problems:
(1) if the directory does not exist we get a fatal error:
(2) if the directory exists but does not have the correct permissions I get:
(3) if the directory does exist and has the correct permissions (777 in my case) and I set it using the GUI, the system still uses "/tmp", not the new directory.
Comment #29
jrockowitz commentedAttached patch fixes the errors.
The 'file_name: 'submission-[webform_submission:serial]'' change can be ignored.
Comment #30
alberto56 commentedNo longer getting fatal errors, however the system is still, in my case, using the /tmp directory.
I noticed that you are making the following change to ./src/WebformSubmissionExporter.php:
However there is another file which contains getFileTempDirectory(), which has not been changed: ./src/Plugin/WebformExporterBase.php
Perhaps making the same change to the above method will cause the configured temporary directory to be used.
Would it also be useful to add some more context to the help text, otherwise users might not understand why we're not just using the /tmp directory. Instead of
something like:
Comment #31
jrockowitz commentedGood catch! and thanks for the editorial suggestion.
Comment #32
alberto56 commentedThis works perfectly in my local tests, thanks! I will deploy this to the production site tomorrow and have more input.
Comment #34
jrockowitz commentedComment #35
alberto56 commentedThanks for taking this on @jrockowitz, I think this will help all Acquia users who are exporting submissions.
I just deployed this to my production and it works exactly as expected: if the config is not set, the default /tmp folder is used, and if the config is set, the custom directory is used.
Comment #36
jrockowitz commented@alberto56 Can you please write a very brief change record? Should just be two sentences and can link to the Acquia article.
You can cut-n-paste info from this ticket and #2221651: Make temporary export file path configurable.
Comment #37
alberto56 commentedOK, here it is, https://www.drupal.org/node/2982200
Comment #39
alberto56 commentedFor reference, there might be a similar issue on the feeds module, see #3010908: Articles are not being imported to production Acquia site, possibly because /tmp folder is not on the same container between requests.
Comment #40
megachriz#3010908: Articles are not being imported to production Acquia site, possibly because /tmp folder is not on the same container between requests is closed as a duplicate, continue in #2912130: Missing temporary files in load balanced environments instead.
Comment #41
krith_18 commentedHi,
Sorry for reopening this ticket.
I face the exact same issue. My codebase is hosted in acquia cloud enterprise and i face the same issue in downloading the webform report.
I went through the patch and it seems like its already incorporated in the webform codebase. I manually compared the patch file and noticed that in src/Form/AdminConfig/WebformAdminConfigExportersForm.php - in this file $config->save(); is missing in 155 line whereas in the patch (https://www.drupal.org/files/issues/2018-06-26/2980276-31.patch) it is there. Is there any reason for that code to be removed? This is my first project using webform.
Do help as this happens in production only. I have created a support ticket in acquia and they gave this patch link.
Thank you in advance!
Regards,
Krithika
Comment #42
baikho commentedHi @krith_18,
Not sure if it solves your problem, but it did for me; can you make sure that you specify the tmp file directory as follows:
See relevant AC documentation: https://docs.acquia.com/acquia-cloud/manage/files/broken/#setting-the-di...
Note that there is a significant difference between Drupal 8/9 and 8.7.x
Comment #43
krith_18 commentedHi @baikho,
Thank you so much!
I will change in settings.php and will deploy to prod and will check.
Once deployed , i will let you know if that works.
Thanks much!
Comment #44
alberto56 commentedRelated to: #3170504: On high-availabilities setups with multiple containers, the /tmp directory might differ between calls, make the error message more descriptive
Comment #45
baikho commentedComment #46
dasginganinjaIn case anybody needed to override this in settings.local.php here is the code:
$config['webform.settings']['export']['temp_directory'] = '/files/tmp-shared-directory';