mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-12 17:05:01 +03:00
b5a04ea95f
emailUsedByOtherInbounds and emailsUsedByOtherInbounds always queried through database.GetDB(), yet five callers run them inside a transaction: both node traffic sync sweeps (setRemoteTrafficLocked), the inbound edit stats sync (updateClientTraffics) and both email-drop branches of UpdateInboundClient. Each call needed a second pool connection while the transaction held row locks on client_traffics/node_client_traffics. On PostgreSQL, once subscription fetches (UPDATE client_traffics SET last_sub_fetch) blocked on those locks filled the rest of the 25-connection pool, the lookup waited forever, the transaction never ended, and the panel hung until restart. Both helpers now take the *gorm.DB to query on; transactional callers pass tx and the rest pass the pool handle they already hold. The new tests cap the pool at one connection, so any query that escapes the transaction blocks; each went red before the fix on SQLite and (node sync) on a live PostgreSQL 16, and passes after. Closes #6789