mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-27 16:25:31 +03:00
fix(service): run inbound deletes and depleted-client purges on the serial traffic writer (#6912)
Inbound and traffic writes are serialised on one goroutine because the traffic poll locks inbounds then client_traffics while an admin mutation does the reverse, which Postgres aborts as a deadlock (40P01). Deleting an inbound and purging depleted clients still opened their own transactions, so they could deadlock the poll, and a delete committing between a concurrent edit's read and its Save let GORM's Save fall back to CREATE and resurrect the inbound. Both now go through runSerializedTx like every other inbound write.
This commit is contained in:
@@ -1651,7 +1651,7 @@ func (s *InboundService) delInbound(id int) (bool, func(), error) {
|
||||
logger.Debug("DelInbound: inbound not found, id:", id)
|
||||
}
|
||||
|
||||
if err := db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := runSerializedTx(func(tx *gorm.DB) error {
|
||||
if err := s.clientService.DetachInbound(tx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user