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

Optimise Matomo 4 updates #16490

Merged
merged 5 commits into from Sep 30, 2020
Merged

Optimise Matomo 4 updates #16490

merged 5 commits into from Sep 30, 2020

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 29, 2020

  • Fix regression in Matomo 4 that dimension updates where no longer shown see Fix when there are dimension updates they aren't shown in the update screen #16491
  • Have quick required schema changes first so UI works mostly (eg user and invalidations table)
  • Group more console updates next to each other by reorganising plugin activates etc
  • Make sure other dimension updates are executed right away so they don't show a second update screen like below

image

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Sep 29, 2020
@tsteur tsteur added this to the 4.0.0-RC milestone Sep 29, 2020
@tsteur tsteur requested a review from sgiehl September 29, 2020 05:32
@@ -53,9 +54,6 @@ public function getMigrations(Updater $updater)
$columnsToAdd = [];

$migrations = [];
$migrations[] = $this->migration->db->changeColumnType('log_action', 'name', 'VARCHAR(4096)');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should avoid slow updates in the beginning and have some required faster ones first

{
$updater->executeMigrations(__FILE__, $this->getMigrations($updater));

if ($this->usesGeoIpLegacyLocationProvider()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was already present in b1 upgrade

@@ -211,7 +241,23 @@ public function getMigrations(Updater $updater)
$migrations[] = $this->migration->config->set('mail', 'type', 'Cram-md5');
}

// keep piwik_ignore for existing installs
$migrations[] = $this->migration->config->set('Tracker', 'ignore_visits_cookie_name', 'piwik_ignore');

$migrations[] = $this->migration->plugin->activate('PagePerformance');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grouping these config and plugin console updates together

$migrations[] = $this->migration->db->changeColumnType('log_action', 'name', 'VARCHAR(4096)');
$migrations[] = $this->migration->db->changeColumnType('log_conversion', 'url', 'VARCHAR(4096)');
$migrations[] = $this->migration->db->changeColumn('log_link_visit_action', 'interaction_position', 'pageview_position', 'MEDIUMINT UNSIGNED DEFAULT NULL');
$migrations[] = $this->migration->db->changeColumnTypes('log_visit', array(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these dimension updates were missing before


/** APP SPECIFIC TOKEN END */
$migrations[] = $this->migration->db->sql("UPDATE `" . Common::prefixTable('option')
. "` SET option_value = 'VARCHAR(40) NULL1' WHERE option_name= 'version_log_visit.config_browser_name'");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO still needs an update for version_log_link_visit_action.pageview_position

@tsteur tsteur added Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. and removed Needs Review PRs that need a code review labels Sep 29, 2020
* @return Migration[]
* @api
*/
public function getMigrations(PiwikUpdater $updater)
Copy link
Member Author

@tsteur tsteur Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes dimension updates were no longer executed (or at least not shown in the UI anymore) see #16491

@@ -18,7 +18,6 @@
class PageViewPosition extends ActionDimension
{
protected $columnName = 'pageview_position';
protected $columnType = 'MEDIUMINT UNSIGNED DEFAULT NULL';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to move this into the schema. Otherwise it would generate an update like this:

ALTER TABLE `matomo_log_link_visit_action` ADD COLUMN `pageview_position ` MEDIUMINT UNSIGNED DEFAULT NULL;

That's because Matomo thinks it is a new dimension and doesn't realise the dimension was actually renamed. This add column alone wouldn't be a problem since the column would already exist and the failure would be ignored. However, it becomes a problem when other dimensions are also changed and the generated SQL looks like this:

ALTER TABLE `matomo_log_link_visit_action` ADD COLUMN `pageview_position ` MEDIUMINT UNSIGNED DEFAULT NULL, ADD COLUMN `other_dimension ` MEDIUMINT UNSIGNED DEFAULT NULL;;

If then the column pageview_position already exists, the SQL would fail and it would not add the second column anymore.

@tsteur tsteur added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Sep 29, 2020
@tsteur
Copy link
Member Author

tsteur commented Sep 29, 2020

Updated the PR so things should work now

@@ -106,10 +128,6 @@ public function getMigrations(Updater $updater)
// Prepare all installed tables for utf8mb4 conversions. e.g. make some indexed fields smaller so they don't exceed the maximum key length
$allTables = DbHelper::getTablesInstalled();

$migrations[] = $this->migration->db->changeColumnType('session', 'id', 'VARCHAR(191)');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved those further up since they are quick to execute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants