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

upgrade script silently fails, but always returns "success" #61

Open
nekromoff opened this issue May 28, 2017 · 2 comments
Open

upgrade script silently fails, but always returns "success" #61

nekromoff opened this issue May 28, 2017 · 2 comments

Comments

@nekromoff
Copy link

nekromoff commented May 28, 2017

The upgrade script is very error prone:
https://github.com/PromInc/organic-search-analytics/blob/master/organic-search-analytics/upgrade.php

as it always returns:

$alert = array("type"=>"success", "message"=>"Upgrade performed succesfully.");

even when error was encountered in the MySQL query.

This is definitely not, how it should behave - specially, since you are suggesting in the multiple issues to run all the upgrade scripts. And people will do and everything will be successful ...or rather not.

Since the script silently fails, but returns success, there is now way to find out if the database tables were upgraded/altered or not.

@nekromoff
Copy link
Author

nekromoff commented May 28, 2017

OK, now I have identified the culprit in the upgrade script:
https://github.com/PromInc/organic-search-analytics/blob/master/organic-search-analytics/upgrade.php#L80

/* Table: search_analytics */
			$query = "ALTER TABLE `search_analytics`".
					 " ADD `page` VARCHAR(500) NULL DEFAULT NULL AFTER `query`,".
					 " CHANGE COLUMN `device_type` `device_type` VARCHAR(24) NULL DEFAULT NULL,".
					 " CHANGE COLUMN `country` `country` VARCHAR(10) NULL DEFAULT NULL,".
					 " CHANGE COLUMN `query` `query` VARCHAR(500) NULL DEFAULT NULL,".
					 " CHANGE COLUMN `avg_position` `avg_position` FLOAT NULL DEFAULT NULL,".
					 " CHANGE COLUMN `avg_position_click` `avg_position_click` FLOAT NULL DEFAULT NULL,".
					 " CONVERT TO CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`"
					 ;

was very slow on 188k+ rows and it timeouted. However, the upgrade script does not say anything, even if it receives back 500 error code (or the AJAX/XHR request timeouts and never returns anything). Therefore user is unaware of the db upgrade fail and thinks everything upgraded fine.

@nekromoff
Copy link
Author

Solution suggested here:
https://stackoverflow.com/questions/12774709/mysql-very-slow-for-alter-table-query
says that one should rather use multiple separate ALTER statements on the large tables to rapidly shorten time needed to modify the table.

Also:

SET unique_checks=0; SET foreign_key_checks=0;

should be run before the ALTER statement.

I think this could fix your upgrade script to perform better and not timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant