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

[Bug] Scheduling re-archiving of custom reports results in archives being deleted for unrelated reports #21620

Closed
4 tasks done
snake14 opened this issue Nov 30, 2023 · 2 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. 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.
Milestone

Comments

@snake14
Copy link
Contributor

snake14 commented Nov 30, 2023

What happened?

When creating a new custom report, it schedules re-archiving so that the past n months (rearchive_reports_in_past_last_n_months) can be archived for the new report. Invalidation records are created for that specific report ID for the past n months. However, when archiving runs, it deletes the archives for other custom reports and doesn't archive the new report for those periods or re-archive the other reports.

What should happen?

The archives of existing reports should be untouched and the new report should be archived for the past n months, based on the rearchive_reports_in_past_last_n_months config.

How can this be reproduced?

First, I run the customreports:archive command to make sure that all of the archives have been created:
image

After creating a new custom report, the blob records are unchanged, but the re-archiving is scheduled:
image
image

When I run the archive process (core:archive) with a breakpoint before the API calls to archive:
image
image
I confirmed that all of the invalidation records had the same report ID.

Once archiving is done running:
image
image

More information is available in my notes on Jira tickets PG-2881 and PG-3173

Matomo major version

Matomo 5

Matomo minor or patch Version

5.0.0-rc8

PHP version

8.1.26

Server operating system

Ubuntu 22.04

What browsers are you seeing the problem on?

Not applicable (e.g. an API call etc.)

Computer operating system

Ubuntu 22.04

Relevant log output

No response

Validations

@snake14 snake14 added Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels Nov 30, 2023
@mneudert
Copy link
Member

mneudert commented Dec 1, 2023

There seems to be something wrong with detecting the RecordBuilder:

if (in_array($record->getName(), $requestedReports)) {
return true;
}

When running the archiving I received some values that obviously won't match:

$recordMetadata = {object[1]} 
 0 = {Piwik\ArchiveProcessor\Record} 
  type = "blob"
  name = "CustomReports_customreport_13_4"
  columnToSortByBeforeTruncation = "nb_visits"
  maxRowsInTable = null
  maxRowsInSubtable = null
  countOfRecordName = null
  countOfRecordNameIsRecursive = false
  columnToRenameAfterAggregation = null
  blobColumnAggregationOps = null
  multiplePeriodTransform = null
$requestedReports = {string[1]} ["13"]
 0 = "13"

If I do some hacky modifications to match that record the previously missing archive blobs appear as expected. Perhaps there is only a call to Archiver::makeRecordName to be patched into an override of RecordBuilder::isBuilderForAtLeastOneOf?

@michalkleiner
Copy link
Contributor

Do you think it's an issue in CustomReports, @mneudert, after changing to use RecordBuilder?

@mneudert mneudert self-assigned this Dec 4, 2023
@mneudert mneudert added Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels Dec 4, 2023
@mneudert mneudert added this to the 5.0.0 milestone Dec 5, 2023
@mneudert mneudert closed this as completed Dec 5, 2023
@mneudert mneudert added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. 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

No branches or pull requests

3 participants