mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6280] [Bug]: Remote-only client's lastOnline stays stale on master while real-time online status is correct #4263
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#4263
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 @gaojiefengxswhuhit on GitHub (Aug 21, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6280
Describe the bug
In a multi-node setup, a client that is assigned only to remote-node inbounds can be detected as online by the master panel, but the same client's
lastOnlineand traffic row on the master remain stale.The remote node itself has the correct, newer
lastOnline, so the inconsistency exists inside 3x-ui's multi-node synchronization rather than in an external UI.This became visible after changing an existing client from local/remote inbound assignments to remote-only inbound assignments.
Environment
install.shclientAObserved behavior
At the time of reproduction:
clientAwas assigned only to two remote-node inbounds.onlineand its API was reachable normally.clientAwas connected, the master could report it as currently online.lastOnlineimmediately fell back to an old timestamp from the previous day.lastOnlinefrom the connection that had just happened.Example (timestamps are real observations, identifiers are redacted):
Master
client_traffics:Remote node
/panel/api/inbounds/list:So the remote node knows the client was online recently, while the master's stored
last_onlineis still about a day old.The master API also returns the same stale
lastOnlinein the remote-backed inbound'sclientStats.Additional clue
On the master,
node_client_trafficscontains baseline rows for other clients on the affected remote node, but no row forclientAon that node, even though the remote node's/panel/api/inbounds/listincludesclientAwith current traffic andlastOnline.There were no
node traffic sync,lastOnline, or online-fetch warnings in the master logs during the reproduction window, and the remote node heartbeat/status was healthy.How to reproduce the problem
This is the sequence that exposed it in my setup:
client_trafficsrow.client_traffics.last_online/ masterinbounds/listclientStatsclient_traffics.last_online/ remoteinbounds/listI have not yet confirmed whether a newly-created remote-only client reproduces it, or whether the trigger specifically requires changing an existing client's inbound ownership/assignment.
Expected behavior
For a client assigned to managed remote-node inbounds, the master should merge the newest remote
lastOnline(and corresponding traffic deltas) into the central client traffic state.At minimum, after the remote node reports a newer timestamp, the master should not continue returning an older
lastOnlinefor that client.Actual behavior
lastOnlineupdates correctly.lastOnlineremains stale.Related issues
I found related reports, but none appears to describe this exact behavior on 3.6.0:
lastOnlineAPI / timeout discussion (different symptom)Relevant logs
No sync warning was emitted during the reproduction window:
Which parts of the panel are affected?
Multi-node (sub-nodes), Statistics / traffic counters, Backend/API
Before submitting
@github-actions[bot] commented on GitHub (Aug 21, 2026):
Your symptom is real, but the code says it is one step earlier than "the master fails to merge a newer
lastOnline": on the master, a node client'slast_online, its traffic delta and itsnode_client_trafficsbaseline are all written by the same loop iteration. So your "additional clue" is not a side observation — it is the proof. A missingnode_client_trafficsrow forclientAon that node means the node'sclientStatsentry forclientAnever reached the merge loop at all. The master is not merging a stale timestamp; it is not mergingclientAfrom that node in the first place.Real-time online status still looks correct because it arrives over a completely different endpoint that never touches the inbound list.
Why the three observations go together
The only place the master writes
last_onlinefor a node-hosted client issetRemoteTrafficLocked, and the baseline upsert is 5 lines below it in the same iteration (internal/web/service/inbound_node.go:904-926):The new-row branch (
inbound_node.go:839-862) does the same pair. There is no path that writes one without the other, so "no baseline row" and "frozenlast_online" are one fact, not two.Online status comes from
panel/api/clients/onlinesByGuid→snap.OnlineTree→process.SetNodeOnlineTree(nodeID, tree)(inbound_node.go:1131), fetched separately ininternal/web/runtime/remote.go:752-763. That is why online is right while the timestamp is a day old.What I could rule out
config_dirtyon the node is not the cause. Theif dirty { continue }guard atinbound_node.go:823-825only fires when the client has noclient_trafficsrow on the master at all, andexistingEmailsis a global email lookup (inbound_node.go:498-513,Where("email IN ?", batch)) — your master row exists, sorowExistsis true and the guard is skipped. A permanently dirty node would still write both.An ambiguous alias match is also out:
inbound_node.go:566returns an error, which would printnode traffic sync: merge for <node> failedevery 5 seconds (cadenceNodeTraffic = "@every 5s",internal/web/web.go:296). You saw no such warnings.That leaves:
clientA's whole node inbound is being dropped from the snapshot the master merges, before the client loop is entered atinbound_node.go:800-803:The confirmed defect underneath it
Whatever drops the inbound, nothing catches it, because the master has no second channel for a node client's last-online.
FetchTrafficSnapshotfetches one on every poll and throws it away:TrafficSnapshot.LastOnlineMap(remote.go:717) is written atremote.go:740andremote.go:769and read nowhere in the Go tree — a per-node HTTP round-trip every 5 seconds whose result is discarded. Contrast the local path, which has exactly this fallback:internal/web/job/xray_traffic_job.go:134callsBumpClientsLastOnline(idleOnline)for clients that are connected but moved no bytes. The node path has no equivalent, so a node client the inbound-list merge skips keeps a frozenlast_onlineindefinitely, with no log line. Identical in v3.6.0 and on the default branch.What I still need to pin the skip
Please run these on the master and paste the output as text (no screenshots):
up/downforclientA's inbound are frozen too, the whole inbound is being skipped, not just the client.clientA(not just the same node) have baseline rows?inbound_sync_modeisselected,FilterNodeSnapshot(internal/web/service/node.go:792-810) silently drops every tag not listed ininbound_tags:tagvalues from step 1 versus thetagvalues in the node's own/panel/api/inbounds/list. A tag the node reports that has nonode_id-matching row on the master is the skip. Note the node filters that endpoint by the requesting user (GetInbounds(user.Id)→Where("user_id = ?", userId),internal/web/service/inbound.go:166), so an inbound owned by a different panel user than the master's API token is visible to your admin query but invisible to the master.collides with an existing inboundandno longer reports inbound. The first is logged once per (node, tag) per process (inbound_node.go:597-606), so it would predate the window you checked.Verdict: Confirmed bug
Severity: Medium
Confidence: Medium
Root cause: Confirmed at
internal/web/runtime/remote.go:765-770+:717— the per-nodepanel/api/clients/lastOnlinefetch is stored inTrafficSnapshot.LastOnlineMapand never read, so the per-inboundclientStatsmerge inInboundService.setRemoteTrafficLocked(internal/web/service/inbound_node.go:904-926) is the sole writer of a node client'slast_onlineon the master, with no fallback and no log when it skips a client. The upstream condition that dropsclientA's inbound from the merged snapshot in this particular deployment is not yet pinned — see "Not determined".Already fixed: Still present on the default branch;
git show v3.6.0:internal/web/runtime/remote.gohas the same unusedLastOnlineMapat lines 672/695/724, and the merge ininbound_node.gois unchanged since v3.6.0 apart from thereset_daycolumn.Duplicate of: None. Related: #4966 (same endpoint, but a 404 on the node, not a discarded response); #4964 was a Postgres
max(bigint, unknown)merge failure that logged loudly — yours logs nothing, which is the distinguishing fact.Evidence:
internal/web/service/inbound_node.go:909reset = ?, reset_day = ?, last_online = %swithdatabase.GreatestExpr("last_online", "?")at :914, paired withs.upsertNodeBaseline(tx, nodeID, cs.Email, canon.Up, canon.Down)at :923 — one iteration writes both, so a missing baseline proves the iteration never ran.inbound_node.go:800-803is the gate that skips a snapshot inbound with no central match.inbound_node.go:823-825if dirty { continue }is reachable only whenrowExistsis false, andexistingEmailsat :498-513 is a globalemail IN (...)lookup, which rules outconfig_dirty.inbound_node.go:1131process.SetNodeOnlineTree(nodeID, tree)fed byremote.go:752-763is the independent online channel.internal/web/service/node.go:793if n == nil || snap == nil || n.InboundSyncMode != "selected" { return }is the tag filter.internal/web/web.go:296cadenceNodeTraffic = "@every 5s".internal/web/job/xray_traffic_job.go:134BumpClientsLastOnline(idleOnline)is the local-path fallback that the node path lacks.Not determined: Which of
FilterNodeSnapshot(selected-mode tag filter), the tag-collision skip atinbound_node.go:597-606, or a node-sideuser_idmismatch onpanel/api/inbounds/listis droppingclientA's inbound in your setup. Item 1 above settles it in one step: if the node inbound's ownup/downon the master are frozen alongside the client's, the inbound is being dropped from the snapshot; if they advance while onlyclientAstays put, the inbound is merged and the client is missing from itsclientStats, which points at the node side instead.Suggested fix: consume the already-fetched
snap.LastOnlineMapinsetRemoteTrafficLockedas aGREATESTmerge for every email the node reports, independent of the per-inboundclientStatswalk — the data is on the wire and discarded today. Separately, an inbound that the snapshot reports but the merge skips should say so once per tag, the wayinbound_node.go:739already does for the reverse case, so this class of failure stops being silent.This reply was generated automatically; a maintainer may follow up.
@gaojiefengxswhuhit commented on GitHub (Aug 21, 2026):
Root cause found on my side: this was a configuration mistake, not a 3x-ui synchronization bug.
The master had the affected node configured as:
With
selectedmode and an empty tag list,FilterNodeSnapshotcorrectly filters out every inbound from that node beforeSetRemoteTraffic, so the remotelastOnline/traffic never reaches the central traffic merge. Real-time online detection could still work through the separate online-status path, which made the symptom look like a sync inconsistency.After changing the node config to:
3x-ui immediately created the
(node,email)baseline and the masterclient_traffics.last_onlineadvanced to the remote node's current timestamp. No 3x-ui code change was needed.Sorry for the false report; closing this as a local configuration error.