mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
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#4230
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 @mrchatam on GitHub (Aug 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6228
This appears to be related to #6113, but the current issue specifically affects clients whose expiration date has passed and is then extended.
The latest release appears to have fixed the similar issue affecting clients with a traffic limit, but expiration-based clients can still be incorrectly removed.
The observed sequence is:
This has happened repeatedly with expiration-based users.
Expected behavior
After extending an expired client, the new expiration date should be synchronized to all relevant inbounds/nodes.
The client should not subsequently be removed because of its previous expiration date.
Actual behavior
The client is removed from the affected node/inbound even though it has been extended.
In this example, the client has
total = 0, so this is not a traffic-limit case.There is also a clear discrepancy between the expiration state of the affected inbound and the other inbounds on the main panel.
Investigation / Database evidence
The affected client is:
The main panel has the client in five other inbounds with the new expiration date, while the affected inbound has stale expiration state.
1. Main panel: client traffic record
Query:
Result:
The important points are:
inbound_id = 44enable = falsetotal = 02026-08-15 23:07:25.763 UTCThe client therefore does not have a configured traffic limit that could explain the removal.
2. Main panel: client configuration across all inbounds
The inbound
settingscolumn is stored astextcontaining JSON.First, I verified the structure:
Result:
The JSON contains a
clientsarray:Result:
I then searched all master inbounds for the affected client:
Result:
The new expiration timestamp:
corresponds to:
Therefore, on the master:
client_trafficsrecord associated with inbound 44 still contains the old expiration date and is disabled.This is the main discrepancy observed during the investigation.
3. Main panel: affected inbound
The affected inbound is:
Query:
Result:
The inbound itself is enabled; the client is what has been removed/disabled.
Node investigation
The corresponding node inbound is:
The node has only these inbounds:
Result:
The node's
settingscolumn is alsotextcontaining JSON:Result:
The JSON structure contains the
clientsarray:Result:
I then searched the node for the affected client:
Result:
I also searched all node inbounds:
Result:
So at the time of investigation,
UN_108021068was no longer present in the node's inbound configuration.4. Node: client traffic
Query:
Result:
Therefore the exact
UN_108021068traffic record was also absent from the node.There is a different local record named
UN_108021068_2:Result:
I have not assumed that this local record represents the removed
UN_108021068; it is included only to document the observed node state.Relevant node logs
The node logs show that the client was repeatedly added after manually reattaching the inbound:
There were also previous client/inbound synchronization operations:
The inbound was manually detached and reattached twice during investigation. Each time, the client was added back to the node, but it was subsequently removed again.
Removal log
The relevant panel debug log is:
The client has
total = 0, and therefore this particular case does not appear to be caused by reaching a configured traffic limit.Relation to #6113
This behavior appears closely related to #6113, where users were incorrectly removed from nodes with:
The latest release appears to have addressed the corresponding problem for users whose removal was caused by their traffic limit.
However, I am still seeing the same general behavior for users whose removal is related to expiration.
The important difference is that these users have:
I am not certain whether the root cause is stale expiration synchronization, the expiration cleanup logic, or another part of the multi-node synchronization process. The database state above is provided to show the discrepancy observed at the time of investigation.
Steps to reproduce
I cannot reproduce this deterministically with a newly created user, but the issue has occurred repeatedly in production with users following this sequence:
Frequency
This is not an isolated occurrence. The same type of issue has occurred repeatedly with expiration-based users.
The current report is specifically about the expiration case. The traffic-limit case appears to have been addressed separately.
Environment
Expected result
After an expired client is extended, its new expiration date should be consistently synchronized across all relevant inbounds and nodes, and the client should remain active until the new expiration date.
Actual result
An affected inbound/node can retain/remove the client based on the previous expiration state, producing:
even though the client has subsequently been extended and remains valid elsewhere on the master.
Please investigate whether the expiration-based removal/synchronization path still has an issue similar to the one addressed for traffic-limit users in #6113.
How to reproduce the problem
extend an expired client on multi node setup
Expected behavior
they client should extend on all nodes and main panel
Actual behavior
instead after extension it will stop working on nodes and even if manually activated the inbound will be removed again
Screenshots
main panel:
node :
3x-ui version
3.6.0
Xray-core version
26.7.28
How did you install 3x-ui?
install.sh script
Operating system
ubuntu 24
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Aug 16, 2026):
Confirmed as a bug, and your reading of the database state is correct: this is a separate defect from the traffic-limit half of #6113, on the node → master expiry merge path. Details below, with the exact files.
Title: node-reported client expiry unconditionally overwrites the master's shared
client_trafficsrow, re-expiring an extended client panel-wideSeverity: High
Category: Correctness
Why this matters
client_traffics.emailis declaredgorm:"unique"(internal/xray/client_traffic.go:9), so there is exactly one accounting row per email for the whole panel — shared by every inbound and every node that email is attached to. That is why your query returned a single row (id 2779) even though the client sits on six inbounds, and it is the reason a single stale writer takes the client down everywhere:On every node poll (
internal/web/job/node_traffic_sync_job.go:409),setRemoteTrafficLockedmerges the node's client stats into that shared row. Theexpiry_timewrite atinternal/web/service/inbound_node.go:898-915adopts the node's value whenever it is positive:The only value it refuses is a non-positive one (the "start after first connect" duration). There is no comparison against the master's own value, and — unlike the settings adoption at
inbound_node.go:664-673— noconfig_dirtyguard on this statement. Any node still holding the pre-extension deadline writes it back over the extended one.The same merge runs
SyncInboundfor node-backed inbounds (inbound_node.go:1038), andapplyClientRecordMergeoverwrites the master'sclientsrow fields outright —row.ExpiryTime = incoming.ExpiryTimeandrow.Enable = incoming.Enableatinternal/web/service/client_link.go:58-59. Note that the same function computesmax(incoming.UpdatedAt, row.UpdatedAt)atclient_link.go:132, so it knows which side is newer but does not use that to decide the merge.The depletion check then runs in the same tick (
node_traffic_sync_job.go:134→AddTraffic).depletedClientsCondLocalis(total > 0 AND up + down >= total) OR (expiry_time > 0 AND expiry_time <= ?)(internal/web/service/inbound_disable.go:60-61). Withtotal = 0only the expiry branch can match — consistent with your observation that this is not a quota case.disableInvalidClientsthen setsclients.enable = falsefor that email withWHERE email IN ?(inbound_disable.go:172-178), i.e. on every inbound, not just the one that reported stale.Config generation drops the client and emits precisely your log line at
internal/web/service/xray.go:196-199, keyed only onclient_traffics.enable.Two things make it self-sustaining rather than a one-off:
ClientTrafficEnableMergeExprisCASE WHEN <node enable> THEN enable ELSE false END(internal/database/dialect.go:40-45): a node reportingenable=falseswitches the master row off, but a node reportingenable=truecan never switch it back on. Only an explicit master-side client edit (UpdateClientStat,internal/web/service/inbound_traffic.go:517-529) restores it — which is exactly why detach/reattach helps for a while and the client then dies again.settingsJSON verbatim (inbound_node.go:673), and the push back to the node re-sends that same stored JSON (buildInboundForNodePush,internal/web/service/inbound.go:1677-1709). Once the node's copy has diverged there is no independent master-side copy left to repair it.Inferred, not confirmed — how inbound 44 got left behind in the first place:
ClientService.Updateiterates the client's inbounds in ascending id order (internal/web/service/client_lookup.go:128) and returns on the first failure (internal/web/service/client_crud.go:427-429), so the highest-id inbound is the one that gets skipped. If the client is already absent from that inbound's stored settings,UpdateInboundClientfails it withempty client ID(internal/web/service/client_inbound_apply.go:579-581). Separately, a failed per-client push to a node is warning-only (client_inbound_apply.go:884-889) after the master has already committed the new expiry.Recommendation
Gate the node-reported
expiry_time/enableadoption on the master's ownclients.updated_atfor that email, so a snapshot older than the last master-side edit cannot roll the deadline back — and skip the adoption entirely whileconfig_dirtyis set, matching the guard already applied to the settings adoption a few lines above. ScopingdisableInvalidClients'clients.enable = falsewrite so one inbound's stale row cannot disable the email on all of them would limit the blast radius as well.Example
Confidence: high for the mechanism above (every step is read from the source and matches your row exactly:
enable = f, oldexpiry_time,total = 0). Medium for which node supplied the stale value — your node 2 no longer reports the email at all, so the stale writer is most likely one of the other two nodes behind inbounds 17/20/22/24/26.To pin that down, could you provide:
SELECT id, remark, node_id, tag FROM inbounds WHERE id IN (17,20,22,24,26,44);— so we know which of those six are node-backed and which node each belongs to.SELECT id, email, enable, expiry_time, updated_at FROM clients WHERE email = 'UN_108021068';— theclientstable is authoritative; thesettingsJSON you queried is a denormalized copy.SELECT email, enable, expiry_time, total FROM client_traffics WHERE email = 'UN_108021068';— one of them should still hold1786835245763.20:45:54containingsetRemoteTrafficorError in updating client on.x-uiversion reported on each node (a node older than the master would explain a one-sided merge).Two notes. I could not read the two attached images, so this is based entirely on your SQL output — please paste any values only visible there as text. Also,
1789427245763converts to2026-09-14 23:07:25 UTCrather than the2026-09-15in your write-up (it is exactly +30 days from the old value); that disagreement is immaterial to the analysis, but flagging it in case the intended extension was 31 days.@MHSanaei for a decision on the fix.
This reply was generated automatically. A maintainer may follow up.
@mrchatam commented on GitHub (Aug 16, 2026):
Master :
xui=> SELECT id, remark, node_id, tag
xui-> FROM inbounds
xui-> WHERE id IN (17, 20, 22, 24, 26, 44)
xui-> ORDER BY id;
id | remark | node_id | tag
----+--------+---------+----------------
17 | 🇩🇪 ME | | in-2053-tcp
20 | 🇫🇮 ME | | in-2055-tcp
22 | 🇫🇷 ME | | in-2058-tcp
24 | 🇺🇸 ME | | in-2060-tcp
26 | 🇳🇱 ME | | in-2062-tcp
44 | 🇹🇷 ME | 3 | n3-in-2087-tcp
(6 rows)
xui=> SELECT id, email, enable, expiry_time, updated_at
xui-> FROM clients
xui-> WHERE email = 'UN_108021068';
id | email | enable | expiry_time | updated_at
-----+--------------+--------+---------------+---------------
538 | UN_108021068 | t | 1789427245763 | 1786894123000
(1 row)
xui=> SELECT
id,
email,
enable,
expiry_time,
to_timestamp(expiry_time / 1000.0) AS expiry_datetime,
updated_at,
to_timestamp(updated_at / 1000.0) AS updated_datetime
FROM clients
xui-> WHERE email = 'UN_108021068';
id | email | enable | expiry_time | expiry_datetime | updated_at | updated_datetime
-----+--------------+--------+---------------+----------------------------+---------------+------------------------
538 | UN_108021068 | t | 1789427245763 | 2026-09-14 23:07:25.763+00 | 1786894123000 | 2026-08-16 15:28:43+00
(1 row)
Master logs:
journalctl -u x-ui --since "2026-08-16 20:44:00" --until "2026-08-16 20:47:00" | grep -i -E "UN_108021068|setRemoteTraffic|Error in updating client on"
Aug 16 20:45:53 ubuntu-4gb-nbg1-2 /usr/local/x-ui/x-ui[2882415]: INFO - Remove Inbound User UN_108021068 due to expiration or traffic limit
Aug 16 20:45:54 ubuntu-4gb-nbg1-2 /usr/local/x-ui/x-ui[2882415]: INFO - Remove Inbound User UN_108021068 due to expiration or traffic limit
Aug 16 20:45:54 ubuntu-4gb-nbg1-2 /usr/local/x-ui/x-ui[2882415]: INFO - Remove Inbound User UN_108021068 due to expiration or traffic limit
Aug 16 20:45:54 ubuntu-4gb-nbg1-2 /usr/local/x-ui/x-ui[2882415]: INFO - Remove Inbound User UN_108021068 due to expiration or traffic limit
Aug 16 20:45:54 ubuntu-4gb-nbg1-2 /usr/local/x-ui/x-ui[2882415]: INFO - Remove Inbound User UN_108021068 due to expiration or traffic limit
node:
xui=> SELECT email, enable, expiry_time, total
xui-> FROM client_traffics
xui-> WHERE email = 'UN_108021068';
email | enable | expiry_time | total
-------+--------+-------------+-------
(0 rows)
xui=> SELECT
email,
enable,
expiry_time,
to_timestamp(expiry_time / 1000.0) AS expiry_datetime,
total,
up,
down,
last_online
FROM client_traffics
xui-> WHERE email = 'UN_108021068';
email | enable | expiry_time | expiry_datetime | total | up | down | last_online
-------+--------+-------------+-----------------+-------+----+------+-------------
(0 rows)
x-ui version on both master and node are 3.6.0 and both xray versions are 26.7.28 , and intended extension was 30 days