Commit 1e2ae4e4463 for woocommerce

commit 1e2ae4e44636cdb4b227adbfc6e4228a325b3483
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date:   Wed May 6 07:58:37 2026 +0200

    [Performance]: Harden stock reservation retry (follow up on #64475) (#64597)

    Follows up on #64475 and addresses use cases when lock identification is affected by the translated error messages.

diff --git a/plugins/woocommerce/src/Checkout/Helpers/ReserveStock.php b/plugins/woocommerce/src/Checkout/Helpers/ReserveStock.php
index e66d229a72b..5b151d5affb 100644
--- a/plugins/woocommerce/src/Checkout/Helpers/ReserveStock.php
+++ b/plugins/woocommerce/src/Checkout/Helpers/ReserveStock.php
@@ -236,10 +236,11 @@ final class ReserveStock {
 		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared

 		// Reliability: high concurrency on the same product reservation can trigger deadlocks (error codes 1213 and 1205).
+		// We currently do not have a reliable method to identify lock errors. The $wpdb interface does not consistently provide
+		// error codes, and error messages can vary by database locale. Previously, we matched messages to 'try restarting transaction'.
 		for ( $attempt = 0; $attempt < 3; ++$attempt ) {
-			$result  = $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
-			$is_lock = false === $result && false !== strpos( $wpdb->last_error, 'try restarting transaction' );
-			if ( ! $is_lock ) {
+			$result = $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
+			if ( false !== $result ) {
 				break;
 			}
 		}