mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4633] [Bug]: Node traffic sync fails with PostgreSQL — max(bigint, unknown) does not exist (SQLSTATE 42883) #3186
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3186
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mrnickson-hue on GitHub (May 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4633
Description
When using 3X-UI with PostgreSQL as the database backend and remote nodes configured, the node traffic sync job fails repeatedly with the following error:
Root Cause
In
web/service/inbound.goaround line 1505, theSetRemoteTrafficfunction executes:MAX(a, b)with two scalar arguments is SQLite-specific syntax that returns the greater of two values. In PostgreSQL,MAX()is an aggregate function (single argument). The PostgreSQL equivalent isGREATEST(a, b).Steps to Reproduce
Expected Behavior
Node traffic sync completes successfully and
last_onlineis updated correctly.Actual Behavior
Sync fails for every node on every cycle, flooding logs with warnings.
Workaround
Create a custom PostgreSQL function that wraps
GREATEST:This makes PostgreSQL resolve
MAX(last_online, $N)correctly until the query is fixed in source.Suggested Fix
In
web/service/inbound.go, replace:with a dialect-aware expression. If GORM dialect detection is available:
GREATEST(last_online, ?)MAX(last_online, ?)Or unconditionally use
GREATESTif SQLite support is dropped for multi-node setups (since PostgreSQL is required for nodes anyway).Environment