ERPNext v14 Deadlock Problem

Hi mate,
Im facing deadlock issue on this table on erpnext 14.5.
heres the error… :

MariaDB thread id 156567, OS thread handle 139842021226048, query id 66811827 localhost 127.0.0.1 _74733d1cee0fd795 Update
INSERT INTO `tabStock Ledger Entry` (`name`, `owner`, `creation`, `modified`, `modified_by`, `docstatus`, `idx`, `item_code`, `warehouse`, `posting_date`, `posting_time`, `is_adjustment_entry`, `voucher_type`, `voucher_no`, `voucher_det>                                        VALUES ('6e54c9845c', 'gebyppangerapan03@gmail.com', '2024-05-18 15:33:47.869454', '2024-05-18 15:33:47.869454', 'gebyppangerapn03@gmail.com', '1', 0, '80870166', 'DC IPILO GUDANG 2 - PTGGS', '20>2024-05-18 15:33:47 156567 [Note] InnoDB: *** WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 3238 page no 70589 n bits 616 index posting_date of table `_74733d1cee0fd795`.`tabStock Ledger Entry` trx id 22098858 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 425 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 3; hex 8fd0b2; asc    ;;
 1: len 10; hex 37303337623634663036; asc 7037b64f06;;

2024-05-18 15:33:47 156567 [Note] InnoDB: *** CONFLICTING WITH:

RECORD LOCKS space id 3238 page no 70589 n bits 616 index posting_date of table `_74733d1cee0fd795`.`tabStock Ledger Entry` trx id 22098867 lock_mode X
Record lock, heap no 277 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

can some show me how to debug it?

@Gembira_IT_Tech Can you please elaborate what exactly you are doing due to this deadlock occurs.

This happens on the production server.
Transactions run as usual but suddenly deadlocks often occur.
The error log above is the log that appears in /var/log/mysql/error.log

here is another log error :

> *** (2) TRANSACTION:
> 
> TRANSACTION 22140842, ACTIVE 1 sec inserting
> mysql tables in use 1, locked 1
> LOCK WAIT 43 lock struct(s), heap size 3488, 40 row lock(s), undo log entries 15
> MariaDB thread id 247357, OS thread handle 139841725142592, query id 106129462 localhost 127.0.0.1 _74733d1cee0fd795 Update
> INSERT INTO `tabSales Team` (`name`, `owner`, `creation`, `modified`, `modified_by`, `docstatus`, `idx`, `sales_person`, `contact_no`, `allocated_percentage`, `allocated_amount`, `commission_rate`, `incentives`, `parent`, `parentfield`,>                                        VALUES ('80311b3e27', 'aldypadja@gmail.com', '2024-05-18 20:50:26.157816', '2024-05-18 20:50:40.986201', 'aldypadja@gmail.com', '0', 1, 'HERLINA YUNUS (a.k.a) LINA', NULL, 100.0e0, 159909.91e0, NU>2024-05-18 20:50:41 247358 [Note] InnoDB: *** WAITING FOR THIS LOCK TO BE GRANTED:
> 
> RECORD LOCKS space id 3197 page no 4428 n bits 480 index parent of table `_74733d1cee0fd795`.`tabSales Team` trx id 22140842 lock_mode X locks gap before rec insert intention waiting
> Record lock, heap no 359 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
>  0: len 16; hex 494e564748572d313232333035383932; asc INVGHW-122305892;;
>  1: len 10; hex 37313438303964646466; asc 714809dddf;;
> 
> 2024-05-18 20:50:41 247358 [Note] InnoDB: *** CONFLICTING WITH:
> 
> RECORD LOCKS space id 3197 page no 4428 n bits 480 index parent of table `_74733d1cee0fd795`.`tabSales Team` trx id 22140842 lock_mode X locks gap before rec
> Record lock, heap no 359 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
>  0: len 16; hex 494e564748572d313232333035383932; asc INVGHW-122305892;;
>  1: len 10; hex 37313438303964646466; asc 714809dddf;;
> 
> RECORD LOCKS space id 3197 page no 4428 n bits 480 index parent of table `_74733d1cee0fd795`.`tabSales Team` trx id 22140843 lock_mode X locks gap before rec
> Record lock, heap no 359 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
>  0: len 16; hex 494e564748572d313232333035383932; asc INVGHW-122305892;;
>  1: len 10; hex 37313438303964646466; asc 714809dddf;;
> 
> 2024-05-18 20:50:41 247358 [Note] InnoDB: *** WE ROLL BACK TRANSACTION (1)

@Gembira_IT_Tech how much data you have in your DB & which version of frappe you are using.