-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Open
Labels
Area: FrameworkComponent: ReportsIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P4No current plan to fix. Fixing can be deferred as a logical part of more important work.No current plan to fix. Fixing can be deferred as a logical part of more important work.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itIssue related to Developer Experience and needs help with Triage to Confirm or Reject it
Description
Preconditions and environment
- 2.4.7-p7
- Large
report_event
table (example data had 5 million rows) - Large
customer_visitor
table (example data had 15 million rows) - Activity that continuously generates new entries in both
report_event
andcustomer_visitor
Steps to reproduce
Cron task that cleans up events can hang indefinitely
// \Magento\Reports\Model\ResourceModel\Event::clean
/**
* Clean report event table
*
* @param \Magento\Reports\Model\Event $object
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function clean(\Magento\Reports\Model\Event $object)
{
while (true) {
$select = $this->getConnection()->select()->from(
['event_table' => $this->getMainTable()],
['event_id']
)->joinLeft(
['visitor_table' => $this->getTable('customer_visitor')],
'event_table.subject_id = visitor_table.visitor_id',
[]
)->where('visitor_table.visitor_id IS NULL')
->where('event_table.subtype = ?', 1)
->limit(1000);
$eventIds = $this->getConnection()->fetchCol($select);
if (!$eventIds) {
break;
}
$this->getConnection()->delete($this->getMainTable(), ['event_id IN(?)' => $eventIds]);
}
return $this;
}
This method has an unconstrained while
loop that can cause the task to never complete.
- Select with join to find matching event_ids on large table takes several seconds to complete
- Simultaneously new events are added from activity on the store
- Delete from table using IDs selected in step 1
- Return to step 1
A simple fix for this issue would be to simply constrain the while loop to a maximum number of iterations, although this may simply push the issue further down the track if the tables continue to grow indefinitely at a certain point the time taken to execute the select will continue to blow-out.
Expected result
Cleanup tasks should not execute indefinitely
Actual result
Cleanup task executes indefinitely
Additional information
No response
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Area: FrameworkComponent: ReportsIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P4No current plan to fix. Fixing can be deferred as a logical part of more important work.No current plan to fix. Fixing can be deferred as a logical part of more important work.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itIssue related to Developer Experience and needs help with Triage to Confirm or Reject it
Type
Projects
Status
Ready for Development