Skip to content

[Bugfix] - Double Calling Collect Totals Breaks MariaDB 11.8 on Magento 2.4.8-p5#154

Open
asim-blueprintprep wants to merge 1 commit into
Affirm:masterfrom
asim-blueprintprep:bugfix/mariadb-innodb-snapshot
Open

[Bugfix] - Double Calling Collect Totals Breaks MariaDB 11.8 on Magento 2.4.8-p5#154
asim-blueprintprep wants to merge 1 commit into
Affirm:masterfrom
asim-blueprintprep:bugfix/mariadb-innodb-snapshot

Conversation

@asim-blueprintprep
Copy link
Copy Markdown
Contributor

@asim-blueprintprep asim-blueprintprep commented May 20, 2026


name: [Bugfix] - Double Calling Collect Totals Breaks MariaDB 11.8 on Magento 2.4.8-p5

Description

After upgrading to Magento 2.4.8-p5 and MariaDB 11.8.6 there is a new MariaDB feature innodb_snapshot_isolation. This now throws an error on trying to run database queries on entries that no longer exist. After placing a successful test order with Affirm 4.0.9 - Any subsequent orders fail with error:

SQLSTATE[HY000]: General error: 1020 Record has changed since last read in table 'quote_shipping_rate', query was: DELETE FROM `quote_shipping_rate` WHERE (rate_id IN ('106'))

This is referencing a shipping rate that has been previously deleted. Older versions of Mariadb silently fail, and handle this gracefully.

This comes from AffirmCheckoutManager::initCheckout() calling collectTotals.
CollectTotals triggers $shippingAddress->collectShippingRates() which calls the delete.

How To Reproduce

Steps to reproduce the behavior:

  1. MariaDB 11.8.6
  2. Affirm 4.0.9
  3. Magento 2.4.8-p5
  4. Place an order locally
  5. Attempt to place a second order locally
  6. Checkout throws an error as above.

Expected behavior

Checkout should popup affirm modal and allow second order to be placed.

Screenshots

Error:
Red blocks to block out PII.
Screenshot 2026-05-19 at 15 53 30

Benefits

It would allow a customer to place multiple orders in succession.

Additional information

This MR wraps collect totals in an if to check if it needs to call collect totals first. This is due to mariadb 11.8.x now having innodb snapshot on, which breaks checkout on double calling collect totals. The error comes from collectTotals triggering $shippingAddress->collectShippingRates() which has already been called. This didnt used to be a problem, and was gracefully handled, but new MariaDB versions now throw an error.

…tals first. This is due to mariadb 11.8.x now having innodb snapshot on, which breaks checkout on double calling collect totals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant