mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5106] [Bug]: node traffic sync: merge for <node> failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804) #3588
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#3588
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 @PrimasIT on GitHub (Jun 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5106
Describe the bug
Environment
Error in x-ui logs
WARNING - X-UI: node traffic sync: merge for failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
The error repeats for every node every few seconds during node traffic sync.
Investigation
The structure of the
node_client_trafficsandnodestables is correct — all numeric fields arebigint, and there is no column-level type mismatch. This indicates the problem is in the merge query itself (INSERT ... ON CONFLICT DO UPDATE), where aCASEexpression mixesbooleanandinteger. This is likely a pattern inherited from the SQLite version, where boolean and 0/1 are interchangeable, but PostgreSQL is strictly typed and rejects it.Note:
node_client_traffics(the sync target) contains no boolean columns — only bigint and text. The boolean type in the failing CASE must therefore come from a join with another table (likelyclient_traffics.enableorinbounds.enable, both boolean) inside the merge query.Impact
VPN connections, panel, and subscriptions work fine — only per-node traffic statistics are affected.
How to reproduce the problem
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.2.8
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Database / migrations
Browser (only if it is a UI bug)
Database bug
Is the panel behind a reverse proxy or CDN?
Yes — Nginx
Before submitting
@github-actions[bot] commented on GitHub (Jun 9, 2026):
Thanks for the detailed report and root-cause analysis, @PrimasIT — you diagnosed it precisely.
Root cause (confirmed in source)
In v3.2.8 the
client_trafficsUPDATE inside the node-traffic merge used a hard-coded SQLite-style CASE expression. PostgreSQL is strict about CASE branch types:enableis boolean but0is integer, so it rejects the query withSQLSTATE 42804.Fix — already merged and released in v3.3.0
Commit
eeb19b72(fix(node-sync): merge client enable with boolean AND for PostgreSQL) introduceddatabase/dialect.go, which now returns a PostgreSQL-aware expression where both branches areboolean(usingfalseinstead of0). PostgreSQL accepts it correctly.Resolution
Upgrade to v3.3.0 (currently pre-release) or wait for it to be promoted to latest:
or re-run the install script. This bug only affects PostgreSQL users on multi-node setups — SQLite is unaffected.
Closing as a duplicate of #5017 (same error, same root cause, fixed in v3.3.0).
Intlfor date formatting #5462