mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 10:36:31 +00:00
fix(stock): fall back gracefully when transaction_advisory_lock is unavailable
Same hasattr pattern as repost_gate: an ERPNext ahead of its frappe build keeps the status-quo serialization-failure retries instead of failing every stock submission on postgres.
This commit is contained in:
@@ -294,8 +294,10 @@ def sle_processing_gate(item_code, warehouse):
|
|||||||
gap locks its previous-SLE locking reads take (which also block, then reveal, concurrent
|
gap locks its previous-SLE locking reads take (which also block, then reveal, concurrent
|
||||||
inserts); postgres locking reads never see rows another transaction is inserting, so without
|
inserts); postgres locking reads never see rows another transaction is inserting, so without
|
||||||
this gate two concurrent writers compute from the same stale previous SLE and the loser's Bin
|
this gate two concurrent writers compute from the same stale previous SLE and the loser's Bin
|
||||||
write is lost. Txn-scoped and re-entrant; released at commit/rollback."""
|
write is lost. Txn-scoped and re-entrant; released at commit/rollback. hasattr keeps a frappe
|
||||||
if frappe.db.db_type == "postgres":
|
predating transaction_advisory_lock on the status quo (serialization-failure retries) instead
|
||||||
|
of breaking every stock submission."""
|
||||||
|
if frappe.db.db_type == "postgres" and hasattr(frappe.db, "transaction_advisory_lock"):
|
||||||
frappe.db.transaction_advisory_lock(("stock-sle", item_code, warehouse), timeout=REPOST_LOCK_TIMEOUT)
|
frappe.db.transaction_advisory_lock(("stock-sle", item_code, warehouse), timeout=REPOST_LOCK_TIMEOUT)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user