Skip to content

Bulk status returning FINISHED_WITH_ERRORS status while is IN_PROGRESS #36911

Open
@obarcelonap

Description

@obarcelonap

Preconditions and environment

  • Magento version: 2.4.5-p1
  • Anything else that would help a developer reproduce the bug

Steps to reproduce

  1. Schedule many operations under same bulk with BulkManagementInterface::scheduleBulk
  2. Before all operations finish the execution get the status of the bulk with BulkStatusInterface::getBulkStatus

Expected result

Bulk status is NOT_STARTED (0) when all operations are OPEN (4)
Bulk status is IN_PROGRESS (1) when at least one operation is OPEN(4)

In other words, bulk status is only in FINISHED_* (2,3) state when all operations are not OPEN(4)

Actual result

Bulk status is FINISHED_WITH_FAILURE (3) when some operations are COMPLETE(1) and OPEN(4).
It returns FINISHED_SUCCESSFULLY (2) once all operations are COMPLETE (1).

Additional information

Logic is implemented in this function:

public function getBulkStatus($bulkUuid)
{
/**
* Number of operations that has been processed (i.e. operations with any status but 'open')
*/
$allProcessedOperationsQty = (int)$this->operationCollectionFactory->create()
->addFieldToFilter('bulk_uuid', $bulkUuid)
->getSize();
if ($allProcessedOperationsQty == 0) {
return BulkSummaryInterface::NOT_STARTED;
}
/**
* Total number of operations that has been scheduled within the given bulk
*/
$allOperationsQty = $this->getOperationCount($bulkUuid);
/**
* Number of operations that has not been started yet (i.e. operations with status 'open')
*/
$allOpenOperationsQty = $allOperationsQty - $allProcessedOperationsQty;
/**
* Number of operations that has been completed successfully
*/
$allCompleteOperationsQty = $this->operationCollectionFactory->create()
->addFieldToFilter('bulk_uuid', $bulkUuid)->addFieldToFilter(
'status',
OperationInterface::STATUS_TYPE_COMPLETE
)->getSize();
if ($allCompleteOperationsQty == $allOperationsQty) {
return BulkSummaryInterface::FINISHED_SUCCESSFULLY;
}
if ($allOpenOperationsQty > 0 && $allOpenOperationsQty !== $allOperationsQty) {
return BulkSummaryInterface::IN_PROGRESS;
}
return BulkSummaryInterface::FINISHED_WITH_FAILURE;
}

I created a dedicated magento module to reproduce the issue (see README file for details):
magento2-gh-36911-main.zip

The execution of the command provided in the module outputs the following log which confirms the issue:

[2023-02-23T12:03:32.740515+00:00] main.INFO: Bulk id created {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.763650+00:00] main.INFO: Scheduled operation 1 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.771172+00:00] main.INFO: Scheduled operation 2 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.777690+00:00] main.INFO: Scheduled operation 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.779483+00:00] main.INFO: Bulk status before executing all operations is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.793993+00:00] main.INFO: Bulk status before consuming operation 1 is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.795633+00:00] main.INFO: Bulk status after consuming operation 1 is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.800481+00:00] main.INFO: Bulk status before consuming operation 2 is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.801980+00:00] main.INFO: Bulk status after consuming operation 2 is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.806389+00:00] main.INFO: Bulk status before consuming operation 3 is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []
[2023-02-23T12:03:32.807890+00:00] main.INFO: Bulk status after consuming operation 3 is 3 {"issue":"gh-36911","bulkId":"2e04e5a5-cfea-434b-95cc-33bb48eea1f3"} []

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

No one assigned

    Labels

    Area: FrameworkComponent: BulkIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: ready for devReported on 2.4.5-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe 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 it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions