mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5017] [Bug]: v.3.2.8 Node traffic sync: merge for {node_name} failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804) #3529
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#3529
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 @shart7 on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5017
Describe the bug
The error appeared after changing the database to PostgreSQL. As I understand it, this is an error of incompatibility of Postgresql and SQLite database variables.
How to reproduce the problem
Add one or more nodes to the panel and view the logs.
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?
Statistics / traffic counters
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No — direct access
Before submitting
@wangzhijie0602 commented on GitHub (Jun 6, 2026):
#4970
@github-actions[bot] commented on GitHub (Jun 6, 2026):
Thanks for the detailed report. I traced this through the source code.
What's happening
The error originates in
web/service/inbound.goinsidesetRemoteTrafficLocked, which runs during every node traffic-sync cycle. For each client stat received from the node it executes (simplified):PostgreSQL raises "CASE types boolean and integer cannot be matched" (SQLSTATE 42804) from the
GREATEST(last_online, $7)call when the two arguments have incompatible types — specifically whenlast_onlineis stored asbooleanin the database while the Go code passes it asbigint(int64).GREATEST(andLEAST,COALESCE,CASE) all use the same internal type-coercion path in PostgreSQL and produce this specific error on a mismatch.The Go model declares
LastOnline int64(→bigint); on a correctly created schema the column isbigint. The mismatch occurs when the PostgreSQL schema differs from what the current code expects — most often because:x-ui migrate-db, leaving boolean columns typed as integers (or vice-versa).last_onlinewith a different type, and GORM'sAutoMigrateon PostgreSQL adds new columns but never alters the type of existing columns, so the stale type is kept.Diagnostic
Connect to your PostgreSQL database and run:
Expected types for the relevant columns:
enablebooleanup,down,total,expiry_time,last_onlinebigintresetintegerSimilarly check the
inboundstable:enablethere must also beboolean.Fix
Preferred (clean slate): Re-run the built-in migration tool, which calls
AutoMigratefirst (creating the correct schema) then copies your data:Then set
XUI_DB_TYPE=postgresandXUI_DB_DSN=...in/etc/default/x-uiand restart.If you need to fix in-place (after identifying the mismatched columns):
Run
systemctl restart x-uiafter any schema change.Clarification needed
To help pinpoint the exact cause, please share:
SELECT column_name, data_type ...queries above.x-ui migrate-db, a manual dump/restore, or something else?@shart7 commented on GitHub (Jun 7, 2026):
Hello!
How you switched from SQLite to PostgreSQL — did you use x-ui migrate-db,
a manual dump/restore, or something else?
I use x-ui migrate-db (menu item 27 -> 2)
Whether you upgraded 3x-ui while already on PostgreSQL (if so, from which
version).
No, I decided to migrate to PostgeSQL using v.3.2.8, before that I used
SQLite.
I use only the original script for installation 3x-ui panel. Today, I tried
to switch to an SQLite database twice, deleted and recreated the PostgreSQL
database using x-ui migrate-db, but the error still persists.
On Sat, Jun 6, 2026 at 6:48 PM Sanaei @.***> wrote:
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'api_tokens'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
name | text
token | text
enabled | boolean
created_at | bigint
(5 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'client_group'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
(0 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'client_inbound'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
(0 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'client_traffics'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
inbound_id | bigint
enable | boolean
email | text
up | bigint
down | bigint
expiry_time | bigint
total | bigint
reset | bigint
last_online | bigint
(10 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'clients'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
email | text
sub_id | text
uuid | text
password | text
auth | text
flow | text
security | text
reverse | text
limit_ip | bigint
total_gb | bigint
expiry_time | bigint
enable | boolean
tg_id | bigint
group_name | text
comment | text
reset | bigint
created_at | bigint
updated_at | bigint
(19 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'custom_geo_resources'
ORDER BY ordinal_position;
column_name | data_type
-----------------+-----------
id | bigint
geo_type | text
alias | text
url | text
local_path | text
last_updated_at | bigint
last_modified | text
created_at | bigint
updated_at | bigint
(9 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'history_of_seeders'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
seeder_name | text
(2 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'inbound_client_ips'
ORDER BY ordinal_position;
column_name | data_type
--------------+-----------
id | bigint
client_email | text
ips | text
(3 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'inbound_fallbacks'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
master_id | bigint
child_id | bigint
name | text
alpn | text
path | text
dest | text
xver | bigint
sort_order | bigint
(9 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'inbounds'
ORDER BY ordinal_position;
column_name | data_type
-------------------------+-----------
id | bigint
user_id | bigint
up | bigint
down | bigint
total | bigint
remark | text
enable | boolean
expiry_time | bigint
traffic_reset | text
last_traffic_reset_time | bigint
listen | text
port | bigint
protocol | text
settings | text
stream_settings | text
tag | text
sniffing | text
node_id | bigint
(18 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'node_client_traffics'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
node_id | bigint
email | text
up | bigint
down | bigint
(5 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'nodes'
ORDER BY ordinal_position;
column_name | data_type
-----------------------+-----------
id | bigint
name | text
remark | text
scheme | text
address | text
port | bigint
base_path | text
api_token | text
enable | boolean
allow_private_address | boolean
tls_verify_mode | text
pinned_cert_sha256 | text
status | text
last_heartbeat | bigint
latency_ms | bigint
xray_version | text
panel_version | text
cpu_pct | numeric
mem_pct | numeric
uptime_secs | bigint
last_error | text
config_dirty | boolean
config_dirty_at | bigint
created_at | bigint
updated_at | bigint
(25 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'outbound_traffics'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
tag | text
up | bigint
down | bigint
total | bigint
(5 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'settings'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
key | text
value | text
(3 rows)
xui=# SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'users'
ORDER BY ordinal_position;
column_name | data_type
-------------+-----------
id | bigint
username | text
password | text
login_epoch | bigint
(4 rows)
Please enter your selection [0-27]: 27
1. Install PostgreSQL (server + client + xui db)
2. Migrate SQLite -> PostgreSQL
3. Status (clusters & port 5432)
4. Start PostgreSQL
5. Stop PostgreSQL
6. Restart PostgreSQL
7. Enable Autostart on boot
8. View PostgreSQL Log
9. Convert SQLite .db <-> .dump
0. Back to Main Menu
Choose an option: 2
This copies your current SQLite data into a PostgreSQL database,
then switches the panel to PostgreSQL and restarts it.
Any existing panel tables in the destination will be cleared and overwritten.
Continue? [Default n]: y
Choose [1]: 1
[INF] Installing PostgreSQL locally (this may take a moment)...
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:2 https://download.docker.com/linux/ubuntu noble InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:4 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Reading package lists... Done
Reading package lists...
Building dependency tree...
Reading state information...
postgresql is already the newest version (16+257build1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Synchronizing state of postgresql.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable postgresql
CREATE ROLE
CREATE DATABASE
ALTER ROLE
[INF] Stopping panel to take a consistent snapshot...
[INF] Migrating data into PostgreSQL...
2026/06/07 15:48:47 Creating destination schema...
2026/06/07 15:48:48 Clearing destination tables...
2026/06/07 15:48:48 User 1 rows
2026/06/07 15:48:48 Setting 85 rows
2026/06/07 15:48:48 HistoryOfSeeders 10 rows
2026/06/07 15:48:48 CustomGeoResource 0 rows
2026/06/07 15:48:48 Node 2 rows
2026/06/07 15:48:48 ApiToken 1 rows
2026/06/07 15:48:48 Inbound 4 rows
2026/06/07 15:48:48 ClientTraffic 12 rows
2026/06/07 15:48:48 OutboundTraffics 0 rows
2026/06/07 15:48:48 InboundClientIps 0 rows
2026/06/07 15:48:48 ClientRecord 12 rows
2026/06/07 15:48:48 ClientInbound 22 rows
2026/06/07 15:48:48 InboundFallback 0 rows
2026/06/07 15:48:48 NodeClientTraffic 2 rows
2026/06/07 15:48:48 Migration complete: 151 rows across 14 tables.
2026/06/07 15:48:48 Set XUI_DB_TYPE=postgres and XUI_DB_DSN=... in /etc/default/x-ui, then restart x-ui.
The OS release is: ubuntu
Arch: amd64
Running...
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:2 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:3 https://download.docker.com/linux/ubuntu noble InRelease
Hit:4 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Reading package lists... Done
Reading package lists...
Building dependency tree...
Reading state information...
cron is already the newest version (3.0pl1-184ubuntu2).
curl is already the newest version (8.5.0-2ubuntu10.9).
tar is already the newest version (1.35+dfsg-3build1).
tzdata is already the newest version (2026a-0ubuntu0.24.04.1).
socat is already the newest version (1.8.0.0-4build3).
ca-certificates is already the newest version (20240203).
openssl is already the newest version (3.0.13-0ubuntu3.9).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Got x-ui latest version: v3.2.8, beginning the installation...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 72.9M 100 72.9M 0 0 73.3M 0 --:--:-- --:--:-- --:--:-- 101M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 111k 100 111k 0 0 450k 0 --:--:-- --:--:-- --:--:-- 452k
x-ui/
x-ui/x-ui.sh
x-ui/x-ui.service.debian
x-ui/x-ui
x-ui/x-ui.service.rhel
x-ui/bin/
x-ui/bin/geosite_RU.dat
x-ui/bin/geoip.dat
x-ui/bin/LICENSE
x-ui/bin/geoip_IR.dat
x-ui/bin/geosite_IR.dat
x-ui/bin/xray-linux-amd64
x-ui/bin/geosite.dat
x-ui/bin/geoip_RU.dat
x-ui/bin/README.md
x-ui/x-ui.service.arch
Username, Password, and WebBasePath are properly set.
SSL certificate already configured. No action needed.
Start migrating database...
Migration done!
Found x-ui.service.debian in extracted files, installing...
Setting up systemd unit...
x-ui v3.2.8 installation finished, it is running now...