Skip to content

Cron - If a misbehaving cron_job starts a transaction it can error and leave the transaction open impacting further jobs run after the misbehaving job #40106

@steven-hoffman-jomashop

Description

Preconditions and environment

  • 2.4.7

Steps to reproduce

A Magento module with a cron job in the default group, with a scheduled time that overlaps with other crons.
The new cron job runs before some other cron jobs.
The new cron job starts a transaction and then throws an error leaving the transaction open.

Expected result

Later cron jobs all start with transaction level=0. (And the DB does not have an open transaction).

Actual result

Later cron jobs all start with transaction level=1. (And the DB has an open transaction).

Also, increased rates of lock wait timeout as the locks taken are kept open until all the cron jobs finish running.

Additional information

Note: It is not currently possible to access all connections from ResourceConnection as the named connections from the connections property are not exposed via a public method.
Note: Closing all connections is possible via closeConnection(null). (Though this may unlock locks held by the ProcessCronQueueObserver)

It would be a significant improvement if ProcessCronQueueObserver checked if the default connection's Transaction level was not equal to 0, and if so, it rolled back until it reached zero. (Or closing the connection; or even aborting would be better than starting a new job with transaction level not equal to zero).

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

    Issue: ready for confirmationReported on 2.4.7Indicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions