[GH-ISSUE #4689] [Bug]: Node traffic sync fails with PostgreSQL — function max(bigint, unknown) does not exist #3239

Closed
opened 2026-10-31 20:31:02 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @SergioSHA1 on GitHub (May 30, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4689

Describe the bug

When using the Nodes feature with a PostgreSQL backend, node traffic sync fails every 5 seconds with the error:
WARNING - node traffic sync: merge for user failed: ERROR: function max(bigint, unknown) does not exist (SQLSTATE 42883)

How to reproduce the problem

Install 3x-ui with PostgreSQL backend (XUI_DB_TYPE=postgres)
Add a remote node via Nodes → Add Node
Enable the node
Check journalctl -u x-ui -f — the error appears every 5 seconds

Expected behavior

Node traffic should sync correctly without SQL errors.

Actual behavior

Traffic sync fails. PostgreSQL does not have a scalar max(bigint, unknown) function — only an aggregate max(bigint). The SQL generated by 3x-ui is incompatible with PostgreSQL.
Traffic sync fails every 5 seconds. PostgreSQL does not have a scalar max(bigint, unknown) function — only an aggregate max(bigint). The SQL generated by 3x-ui is incompatible with PostgreSQL.
Temporary workaround (tested on PostgreSQL 14):
```sql
CREATE OR REPLACE FUNCTION max(bigint, bigint)
RETURNS bigint AS
SELECT GREATEST($1, $2);
LANGUAGE SQL IMMUTABLE STRICT;
```
After creating this function and restarting x-ui, the error disappears and node traffic sync works correctly.

Relevant logs

May 30 13:51:23 /usr/local/x-ui/x-ui: WARNING - node traffic sync: merge for user failed: ERROR: function max(bigint, unknown) does not exist (SQLSTATE 42883)
May 30 13:51:28 /usr/local/x-ui/x-ui: WARNING - node traffic sync: merge for user failed: ERROR: function max(bigint, unknown) does not exist (SQLSTATE 42883)

Screenshots

No response

3x-ui version

3.2.0

Xray-core version

26.5.9

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 22.04

Which parts of the panel are affected?

Statistics / traffic counters, Multi-node (sub-nodes)

Browser (only if it is a UI bug)

N/A (not a UI bug)

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @SergioSHA1 on GitHub (May 30, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4689 ### Describe the bug When using the Nodes feature with a PostgreSQL backend, node traffic sync fails every 5 seconds with the error: WARNING - node traffic sync: merge for user failed: ERROR: function max(bigint, unknown) does not exist (SQLSTATE 42883) ### How to reproduce the problem Install 3x-ui with PostgreSQL backend (XUI_DB_TYPE=postgres) Add a remote node via Nodes → Add Node Enable the node Check journalctl -u x-ui -f — the error appears every 5 seconds ### Expected behavior Node traffic should sync correctly without SQL errors. ### Actual behavior Traffic sync fails. PostgreSQL does not have a scalar max(bigint, unknown) function — only an aggregate max(bigint). The SQL generated by 3x-ui is incompatible with PostgreSQL. Traffic sync fails every 5 seconds. PostgreSQL does not have a scalar max(bigint, unknown) function — only an aggregate max(bigint). The SQL generated by 3x-ui is incompatible with PostgreSQL. **Temporary workaround** (tested on PostgreSQL 14): \```sql CREATE OR REPLACE FUNCTION max(bigint, bigint) RETURNS bigint AS $$ SELECT GREATEST($1, $2); $$ LANGUAGE SQL IMMUTABLE STRICT; \``` After creating this function and restarting x-ui, the error disappears and node traffic sync works correctly. ### Relevant logs ```shell May 30 13:51:23 /usr/local/x-ui/x-ui: WARNING - node traffic sync: merge for user failed: ERROR: function max(bigint, unknown) does not exist (SQLSTATE 42883) May 30 13:51:28 /usr/local/x-ui/x-ui: WARNING - node traffic sync: merge for user failed: ERROR: function max(bigint, unknown) does not exist (SQLSTATE 42883) ``` ### Screenshots _No response_ ### 3x-ui version 3.2.0 ### Xray-core version 26.5.9 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 22.04 ### Which parts of the panel are affected? Statistics / traffic counters, Multi-node (sub-nodes) ### Browser (only if it is a UI bug) N/A (not a UI bug) ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:31:02 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ariashamshiri commented on GitHub (May 31, 2026):

Please fix.

<!-- gh-comment-id:4586744828 --> @ariashamshiri commented on GitHub (May 31, 2026): Please fix.
Author
Owner

@Leonid-Perkin commented on GitHub (Jun 5, 2026):

in version 3.2.8, the error returned again.
X-UI: node traffic sync: merge forrufailed:ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)

<!-- gh-comment-id:4631463396 --> @Leonid-Perkin commented on GitHub (Jun 5, 2026): in version 3.2.8, the error returned again. X-UI: node traffic sync: merge forrufailed:ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3239
No description provided.