[GH-ISSUE #5106] [Bug]: node traffic sync: merge for <node> failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804) #3588

Closed
opened 2026-10-31 20:33:31 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @PrimasIT on GitHub (Jun 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5106

Describe the bug

Environment

  • x-ui: 3.2.8
  • xray: 26.6.1
  • Database: PostgreSQL 16.14
  • OS: Ubuntu 24.04
  • Setup: multi-node (main panel + attached nodes)

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.

Image

Investigation
The structure of the node_client_traffics and nodes tables is correct — all numeric fields are bigint, and there is no column-level type mismatch. This indicates the problem is in the merge query itself (INSERT ... ON CONFLICT DO UPDATE), where a CASE expression mixes boolean and integer. 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 (likely client_traffics.enable or inbounds.enable, both boolean) inside the merge query.

Impact
VPN connections, panel, and subscriptions work fine — only per-node traffic statistics are affected.

Image Image Image

How to reproduce the problem

  1. Install multiple 3x-ui instances, each with PostgreSQL as the database.
  2. Connect them to each other as nodes (one main panel + attached nodes).
  3. Check the x-ui logs on the main panel — the "node traffic sync" error appears repeatedly. As a result, received/sent traffic for the other nodes is not displayed on the main 3x-ui.

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

  • 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 @PrimasIT on GitHub (Jun 9, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5106 ### Describe the bug **Environment** - x-ui: 3.2.8 - xray: 26.6.1 - Database: PostgreSQL 16.14 - OS: Ubuntu 24.04 - Setup: multi-node (main panel + attached nodes) **Error in x-ui logs** WARNING - X-UI: node traffic sync: merge for <node> 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. <img width="620" height="654" alt="Image" src="https://github.com/user-attachments/assets/d8fca0a8-3749-4256-afed-eb819b2b4331" /> **Investigation** The structure of the `node_client_traffics` and `nodes` tables is correct — all numeric fields are `bigint`, and there is no column-level type mismatch. This indicates the problem is in the merge query itself (`INSERT ... ON CONFLICT DO UPDATE`), where a `CASE` expression mixes `boolean` and `integer`. 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 (likely `client_traffics.enable` or `inbounds.enable`, both boolean) inside the merge query. **Impact** VPN connections, panel, and subscriptions work fine — only per-node traffic statistics are affected. <img width="1089" height="801" alt="Image" src="https://github.com/user-attachments/assets/b42b887d-d7ce-47ba-bab4-4aa62737db0d" /> <img width="1070" height="516" alt="Image" src="https://github.com/user-attachments/assets/c016b477-f630-4b2d-8b74-71f30528796d" /> <img width="929" height="863" alt="Image" src="https://github.com/user-attachments/assets/24bab42a-d38b-4d51-b830-99bb994a5b44" /> ### How to reproduce the problem 1. Install multiple 3x-ui instances, each with PostgreSQL as the database. 2. Connect them to each other as nodes (one main panel + attached nodes). 3. Check the x-ui logs on the main panel — the "node traffic sync" error appears repeatedly. As a result, received/sent traffic for the other nodes is not displayed on the main 3x-ui. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### 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 - [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:33:31 +07:00
Author
Owner

@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_traffics UPDATE inside the node-traffic merge used a hard-coded SQLite-style CASE expression. PostgreSQL is strict about CASE branch types: enable is boolean but 0 is integer, so it rejects the query with SQLSTATE 42804.

Fix — already merged and released in v3.3.0

Commit eeb19b72 (fix(node-sync): merge client enable with boolean AND for PostgreSQL) introduced database/dialect.go, which now returns a PostgreSQL-aware expression where both branches are boolean (using false instead of 0). PostgreSQL accepts it correctly.

Resolution

Upgrade to v3.3.0 (currently pre-release) or wait for it to be promoted to latest:

x-ui   # choose option 1 (Install/Update) from the management menu

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).

<!-- gh-comment-id:4655119937 --> @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_traffics` UPDATE inside the node-traffic merge used a hard-coded SQLite-style CASE expression. PostgreSQL is strict about CASE branch types: `enable` is **boolean** but `0` is **integer**, so it rejects the query with `SQLSTATE 42804`. **Fix — already merged and released in v3.3.0** Commit `eeb19b72` (`fix(node-sync): merge client enable with boolean AND for PostgreSQL`) introduced `database/dialect.go`, which now returns a PostgreSQL-aware expression where both branches are `boolean` (using `false` instead of `0`). PostgreSQL accepts it correctly. **Resolution** Upgrade to **v3.3.0** (currently pre-release) or wait for it to be promoted to latest: ```bash x-ui # choose option 1 (Install/Update) from the management menu ``` 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).
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#3588
No description provided.