Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpMyAdmin no longer streams the export data #14478

Closed
erolatreston opened this issue Jul 10, 2018 · 11 comments
Closed

phpMyAdmin no longer streams the export data #14478

erolatreston opened this issue Jul 10, 2018 · 11 comments
Assignees
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
Milestone

Comments

@erolatreston
Copy link
Contributor

Prior to phpMyAdmin 4.8, export would almost immediately start exporting and stream the export data as it processes the tables. Since 4.8, phpMyAdmin seems to generate the export sql file on the server side and does not start the download until all tables are exported into the sql file. If there are too many tables to export, the operation may fail with a timeout.

Steps to reproduce

  1. Go to Export tab
  2. Select "Custom - display all possible options" option
  3. Select a database with a lot of tables
  4. Click on "Go" button

Expected behaviour

The export sql file download starts immediately and continues streaming the export data until all tables are processed.

Actual behaviour

The export sql file download does not start immediately. Monitoring MySQL shows that phpMyAdmin is busy generating the export data. After all tables are processed, the download starts if the export operation has not timed out.

Server configuration

Operating system:
CentOS

Web server:
Apache/2.4.6 (CentOS)

Database:
mysql 5.7.22

PHP version:
PHP 5.6.36 (cli) (built: Apr 27 2018 10:29:07)

phpMyAdmin version:
4.8.2

Client configuration

Chrome
MacOS

@lem9
Copy link
Contributor

lem9 commented Jul 11, 2018

Please explain what you mean by "at lot of tables" in terms of the number of tables and the total size of them.

@erolatreston
Copy link
Contributor Author

erolatreston commented Jul 11, 2018

We have around 10,000 tables. They are very simple tables with ~2,3 columns. They also contain small number of rows - less than 10 on average.

Prior to 4.8.0, the export would immediately start the download of the export data. phpMyAdmin would stream the data to the browser as it is processing the tables. After 4.8.0, phpMyAdmin seems to generate the entire export data and only send the export file to the client after all tables have been processed.

@ghost
Copy link

ghost commented Jul 15, 2018

i try to export data only (350,000 rows) in v4.8.1, after click the run, the whole screen freeze and saw the server memory usage 100%, after a few mins, the SAVE button window popup

but in v4.6.6, click the run, will first show the SAVE button window, then will use less memory just like read and write, read and write

@jeff-kilbride
Copy link

Possibly the same issue. The export function no longer works with 4.8.2 on Amazon RDS. After clicking the "Go" button and a slight delay, I get a "File Not Found" error for export.php.

@jeff-kilbride
Copy link

Here are the log messages from nginx (sanitized):

[2018-08-06T19:42:23+00:00] xxx.xxx.xxx.xxx - - "GET /db_export.php?db=mydb_prod&ajax_request=true&ajax_page_request=true&_nocache=1533584543637653740&token=IGUX9%7C_cbw%2C1(xZ~ HTTP/2.0" 200 13653 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
[2018-08-06T19:42:44+00:00] xxx.xxx.xxx.xxx - - "POST /export.php HTTP/2.0" 500 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:61.0) Gecko/20100101 Firefox/61.0" "-"

@jeff-kilbride
Copy link

Also found the following in PHP logs:

[06-Aug-2018 19:42:43 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 82887119 bytes) in /var/www/html/libraries/classes/OutputBuffering.php on line 132
[06-Aug-2018 19:42:43 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

@williamdes williamdes self-assigned this Nov 30, 2018
@williamdes
Copy link
Member

Git bisect found that the fist bad commit is 9f27920 and I agree since calling Response::getInstance() calls the constructor that does OutputBuffering::start() and the start function contains ob_start('ob_gzhandler'); and ob_start();.

Comment the lines out and the export works again for large tables !

williamdes added a commit to williamdes/phpmyadmintest that referenced this issue Jan 1, 2019
Fixes: phpmyadmin#14478

Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes williamdes added Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete labels Jan 1, 2019
MauricioFauth added a commit that referenced this issue Jan 28, 2019
Fix #14478 - phpMyAdmin no longer streams the export data
MauricioFauth added a commit that referenced this issue Jan 28, 2019
[ci skip]

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
@MauricioFauth MauricioFauth modified the milestones: 5.0.0, 4.8.6 Jan 28, 2019
@prcdpr
Copy link

prcdpr commented Mar 25, 2020

It's still broken on 5.0.2, I had to go back to 4.9.5 for working exports. On 5.0.2 I get out of memory error, while on 4.9.5 it works flawlessly.

Please reopen this bug

@williamdes williamdes reopened this Mar 25, 2020
@williamdes williamdes added this to Needs triage in issues via automation Mar 25, 2020
@williamdes williamdes moved this from Needs triage to High priority in issues Mar 25, 2020
@Elodie81
Copy link

Thank you very much @williamdes and @prcdpr :) I have exactly the same problem with PhpMyAdmin 5.0.2 and after removed the 2 lines "ob_start('ob_gzhandler');" and "ob_start();" (as indicate at 26 Dec 2018) exports of big data are working again.

@williamdes williamdes modified the milestones: 4.9.0.1, 5.0.3 Apr 18, 2020
@williamdes
Copy link
Member

diff --git a/export.php b/export.php
index b1bf50a3079..206e84a0dbb 100644
--- a/export.php
+++ b/export.php
@@ -285,7 +285,7 @@ if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit' && ! $
     $response->disable();
     //Disable all active buffers (see: ob_get_status(true) at this point)
     do {
-        if (ob_get_length() > 0) {
+        if (ob_get_length() > 0 || ob_get_level() > 0) {
             $hasBuffer = ob_end_clean();
         } else {
             $hasBuffer = false;

williamdes added a commit that referenced this issue Jun 10, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes
Copy link
Member

Hi everybody,
After some investigation I discovered that the length was 0 but that we where in another nesting level
So I added a condition to empty all levels and fix the data stream.

Could you try my fix ?

issues automation moved this from High priority to Closed Jun 10, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
issues
  
Closed
Development

No branches or pull requests

7 participants