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

Fix segment update scripts #17532

Merged
merged 1 commit into from May 7, 2021
Merged

Fix segment update scripts #17532

merged 1 commit into from May 7, 2021

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented May 7, 2021

Description:

Updating Matomo might currently fail, as the update script for 4.3.0-b4 tries to use the hash column, which is created in update for 4.3.0-b3. As the migrations are all gathered before they are executed, the hash column does not exist and the query fails.
This also happen for our updater UI test. See https://travis-ci.com/github/matomo-org/matomo/jobs/503575602#L1700

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@sgiehl sgiehl added Critical Indicates the severity of an issue is very critical and the issue has a very high priority. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Regression Indicates a feature used to work in a certain way but it no longer does even though it should. labels May 7, 2021
@sgiehl sgiehl added this to the 4.3.0 milestone May 7, 2021
@sgiehl sgiehl requested a review from diosmosis May 7, 2021 11:53
foreach ($segments as $segment) {
$hash = md5(urldecode($segment['definition']));
$migrations[] = $this->migration->db->sql("UPDATE `$segmentTable` SET `hash` = '$hash' WHERE `idsegment` = '{$segment['idsegment']}'");
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing this one, as otherwise all segments might be updated twice when updating from a version prior 4.3.0-b3

@diosmosis diosmosis merged commit 951fd1d into 4.x-dev May 7, 2021
@diosmosis diosmosis deleted the fixupdate branch May 7, 2021 15:50
@tsteur
Copy link
Member

tsteur commented May 9, 2021

@sgiehl not fully sure I understand the problem. Updating it twice be fine I suppose as it's quick etc and this way people that copy/paste the queries and execute them manually could do this (although it should then be executed again anyway hopefully). Curious though how came it failed cause the hash column should have been added before the update query was executed. Was this not the case? Just checking in case there's a bug somewhere

@diosmosis
Copy link
Member

@tsteur the hash column was selected outside of a migration, so the migration that added the column would get executed after the query that used it was executed. This was the best fix I think.

@diosmosis
Copy link
Member

I assume it was just a waste to have both sets of queries since they do the same thing.

@sgiehl
Copy link
Member Author

sgiehl commented May 10, 2021

I assume it was just a waste to have both sets of queries since they do the same thing.

Exactly

@tsteur
Copy link
Member

tsteur commented May 10, 2021

In that case it was to show the updates it would run and then make sure it will be executed just in case either step will be missed in which case it could lead to data deletion of reports that may not be possible to be recreated etc. I reckon it could be good to add it back just to be safe as it's a very critical update that if it goes wrong reports get deleted and then if raw data deletion is configured as well the reports are gone forever or they would need to invalidate data which isn't easy either and can take long time to rearchive data.

@sgiehl
Copy link
Member Author

sgiehl commented May 11, 2021

Still don't get why it would be better to execute the same sql queries twice. I have removed the one in the earlier update script. So even if someone already was on 4.3.0-b3, the updates will be performed again if needed 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical Indicates the severity of an issue is very critical and the issue has a very high priority. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants