[GH-ISSUE #6228] [Bug]: Users are incorrectly removed due to expiration in multi-node setup despite having remaining quota similar to the #6113 issue but only for users with expirations #4230

Closed
opened 2026-10-31 20:38:08 +07:00 by bsakaguchi · 2 comments
Owner

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:

  1. A client reaches its expiration date.
  2. The client is extended to a new expiration date.
  3. The client continues to work correctly on the main panel/other inbounds.
  4. An affected node/inbound later removes the client.
  5. The panel logs:
2026/08/16 20:45:54 INFO - X-UI: Remove Inbound User UN_108021068 due to expiration or traffic limit
  1. Manually detaching and reattaching the affected inbound adds the client back to the node.
  2. The client is subsequently removed again.

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:

UN_108021068

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:

SELECT
    id,
    inbound_id,
    email,
    enable,
    up,
    down,
    total,
    expiry_time,
    to_timestamp(expiry_time / 1000.0) AS expiry_datetime,
    reset,
    last_online
FROM client_traffics
WHERE email = 'UN_108021068'
ORDER BY inbound_id;

Result:

  id  | inbound_id |    email     | enable |     up     |     down     | total |  expiry_time  |      expiry_datetime       | reset |   last_online
------+------------+--------------+--------+------------+--------------+-------+---------------+----------------------------+-------+----------------
 2779 |         44 | UN_108021068 | f      | 5831406730 | 202797377491 |     0 | 1786835245763 | 2026-08-15 23:07:25.763+00 |     0 | 1786917060070

The important points are:

  • inbound_id = 44
  • enable = false
  • total = 0
  • expiration is still 2026-08-15 23:07:25.763 UTC

The client therefore does not have a configured traffic limit that could explain the removal.


2. Main panel: client configuration across all inbounds

The inbound settings column is stored as text containing JSON.

First, I verified the structure:

SELECT id, remark, pg_typeof(settings)
FROM inbounds
WHERE id = 44;

Result:

 id | remark | pg_typeof
----+--------+-----------
 44 | 🇹🇷 ME  | text

The JSON contains a clients array:

SELECT jsonb_object_keys(settings::jsonb)
FROM inbounds
WHERE id = 44;

Result:

 jsonb_object_keys
-------------------
 clients

I then searched all master inbounds for the affected client:

SELECT
    id,
    remark,
    client ->> 'email' AS email,
    client ->> 'enable' AS enable,
    client ->> 'expiryTime' AS expiry_time,
    client ->> 'totalGB' AS total_gb,
    client ->> 'updated_at' AS updated_at
FROM inbounds,
     jsonb_array_elements(settings::jsonb -> 'clients') AS client
WHERE client ->> 'email' = 'UN_108021068'
ORDER BY id;

Result:

 id | remark |    email     | enable |  expiry_time  | total_gb |   updated_at
----+--------+--------------+--------+---------------+----------+----------------
 17 | 🇩🇪 ME | UN_108021068 | true   | 1789427245763 | 0        | 1786893780000
 20 | 🇫🇮 ME | UN_108021068 | true   | 1789427245763 | 0        | 1786893780000
 22 | 🇫🇷 ME | UN_108021068 | true   | 1789427245763 | 0        | 1786893780000
 24 | 🇺🇸 ME | UN_108021068 | true   | 1789427245763 | 0        | 1786893780000
 26 | 🇳🇱 ME | UN_108021068 | true   | 1789427245763 | 0        | 1786893780000

The new expiration timestamp:

1789427245763

corresponds to:

2026-09-15 23:07:25.763 UTC

Therefore, on the master:

  • Inbounds 17, 20, 22, 24 and 26 contain the client with the new expiration date.
  • Inbound 44 does not contain the client anymore.
  • The client_traffics record 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:

id = 44
remark = 🇹🇷 ME
enable = true

Query:

SELECT id, remark, enable
FROM inbounds
WHERE id = 44;

Result:

 id | remark | enable
----+--------+--------
 44 | 🇹🇷 ME | t

The inbound itself is enabled; the client is what has been removed/disabled.


Node investigation

The corresponding node inbound is:

id = 2
remark = 🇹🇷 ME

The node has only these inbounds:

SELECT id, remark, enable, port, protocol
FROM inbounds
ORDER BY id;

Result:

 id | remark | enable | port | protocol
----+--------+--------+------+----------
  2 | 🇹🇷 ME | t      | 2087 | vmess
  4 | 🇹🇷 HK | t      | 2088 | vmess

The node's settings column is also text containing JSON:

SELECT pg_typeof(settings)
FROM inbounds
WHERE id = 2;

Result:

 pg_typeof
-----------
 text

The JSON structure contains the clients array:

SELECT jsonb_object_keys(settings::jsonb)
FROM inbounds
WHERE id = 2;

Result:

 jsonb_object_keys
-------------------
 clients

I then searched the node for the affected client:

SELECT
    client ->> 'email' AS email,
    client ->> 'enable' AS enable,
    client ->> 'expiryTime' AS expiry_time,
    client ->> 'totalGB' AS total_gb,
    client ->> 'updated_at' AS updated_at
FROM inbounds,
     jsonb_array_elements(settings::jsonb -> 'clients') AS client
WHERE id = 2
  AND client ->> 'email' = 'UN_108021068';

Result:

 email | enable | expiry_time | total_gb | updated_at
-------+--------+-------------+----------+-----------
(0 rows)

I also searched all node inbounds:

SELECT
    id,
    remark,
    client ->> 'email' AS email,
    client ->> 'enable' AS enable,
    client ->> 'expiryTime' AS expiry_time,
    client ->> 'totalGB' AS total_gb,
    client ->> 'updated_at' AS updated_at
FROM inbounds,
     jsonb_array_elements(settings::jsonb -> 'clients') AS client
WHERE client ->> 'email' = 'UN_108021068'
ORDER BY id;

Result:

(0 rows)

So at the time of investigation, UN_108021068 was no longer present in the node's inbound configuration.


4. Node: client traffic

Query:

SELECT *
FROM client_traffics
WHERE email = 'UN_108021068';

Result:

(0 rows)

Therefore the exact UN_108021068 traffic record was also absent from the node.

There is a different local record named UN_108021068_2:

SELECT *
FROM client_traffics
WHERE email ILIKE '%UN_108021068%';

Result:

 id | inbound_id | enable |      email       |  up   | down  |  expiry_time  | total | reset |   last_online
----+------------+--------+------------------+-------+-------+---------------+-------+-------+----------------
 852 |          2 | t      | UN_108021068_2   | 20108 | 46795 | 1789485822549 |     0 |     0 | 1786917273063

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:

2026/08/16 15:28:43 DEBUG - X-UI: Client added onlocal:UN_108021068
2026/08/16 15:22:28 DEBUG - X-UI: Client added onlocal:UN_108021068
2026/08/16 09:08:14 DEBUG - X-UI: Client added onlocal:UN_108021068

There were also previous client/inbound synchronization operations:

2026/08/12 05:52:34 DEBUG - X-UI: Client edited onlocal:UN_108021068
2026/08/12 05:52:34 DEBUG - X-UI: Old client deleted onlocal:UN_108021068

2026/08/12 05:49:00 DEBUG - X-UI: Updated inbound added onlocal:in-2088-tcp
2026/08/12 05:49:00 DEBUG - X-UI: Old inbound deleted onlocal:in-2088-tcp

2026/08/12 05:48:59 DEBUG - X-UI: Client edited onlocal:UN_108021068
2026/08/12 05:48:59 DEBUG - X-UI: Old client deleted onlocal:UN_108021068

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:

2026/08/16 20:45:54 INFO - X-UI: Remove Inbound User UN_108021068 due to expiration or traffic limit

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:

Remove Inbound User [username] due to expiration or traffic limit

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:

  1. expired,
  2. subsequently been extended,
  3. received the new expiration date on other inbounds,
  4. but an affected inbound/node can still retain stale expiration state and later remove the client.

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:

  1. Create a client with an expiration date.
  2. Allow the client to expire.
  3. Extend the client after expiration.
  4. The client receives the new expiration date on the main panel/other inbounds.
  5. An affected node/inbound eventually removes the client.
  6. The panel logs:
Remove Inbound User [email] due to expiration or traffic limit
  1. Detaching and reattaching the affected inbound restores the client temporarily.
  2. The client can subsequently be removed again.

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

  • 1 main/master panel
  • 3 nodes in the overall deployment
  • PostgreSQL
  • Multi-node configuration
  • Latest 3x-ui release at the time of reporting

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:

Remove Inbound User UN_108021068 due to expiration or traffic limit

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:

Image

node :

Image

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

  • 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 @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: 1. A client reaches its expiration date. 2. The client is extended to a new expiration date. 3. The client continues to work correctly on the main panel/other inbounds. 4. An affected node/inbound later removes the client. 5. The panel logs: ```text 2026/08/16 20:45:54 INFO - X-UI: Remove Inbound User UN_108021068 due to expiration or traffic limit ``` 6. Manually detaching and reattaching the affected inbound adds the client back to the node. 7. The client is subsequently removed again. 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: ```text UN_108021068 ``` 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: ```sql SELECT id, inbound_id, email, enable, up, down, total, expiry_time, to_timestamp(expiry_time / 1000.0) AS expiry_datetime, reset, last_online FROM client_traffics WHERE email = 'UN_108021068' ORDER BY inbound_id; ``` Result: ```text id | inbound_id | email | enable | up | down | total | expiry_time | expiry_datetime | reset | last_online ------+------------+--------------+--------+------------+--------------+-------+---------------+----------------------------+-------+---------------- 2779 | 44 | UN_108021068 | f | 5831406730 | 202797377491 | 0 | 1786835245763 | 2026-08-15 23:07:25.763+00 | 0 | 1786917060070 ``` The important points are: * `inbound_id = 44` * `enable = false` * `total = 0` * expiration is still `2026-08-15 23:07:25.763 UTC` The client therefore does not have a configured traffic limit that could explain the removal. --- ### 2. Main panel: client configuration across all inbounds The inbound `settings` column is stored as `text` containing JSON. First, I verified the structure: ```sql SELECT id, remark, pg_typeof(settings) FROM inbounds WHERE id = 44; ``` Result: ```text id | remark | pg_typeof ----+--------+----------- 44 | 🇹🇷 ME | text ``` The JSON contains a `clients` array: ```sql SELECT jsonb_object_keys(settings::jsonb) FROM inbounds WHERE id = 44; ``` Result: ```text jsonb_object_keys ------------------- clients ``` I then searched all master inbounds for the affected client: ```sql SELECT id, remark, client ->> 'email' AS email, client ->> 'enable' AS enable, client ->> 'expiryTime' AS expiry_time, client ->> 'totalGB' AS total_gb, client ->> 'updated_at' AS updated_at FROM inbounds, jsonb_array_elements(settings::jsonb -> 'clients') AS client WHERE client ->> 'email' = 'UN_108021068' ORDER BY id; ``` Result: ```text id | remark | email | enable | expiry_time | total_gb | updated_at ----+--------+--------------+--------+---------------+----------+---------------- 17 | 🇩🇪 ME | UN_108021068 | true | 1789427245763 | 0 | 1786893780000 20 | 🇫🇮 ME | UN_108021068 | true | 1789427245763 | 0 | 1786893780000 22 | 🇫🇷 ME | UN_108021068 | true | 1789427245763 | 0 | 1786893780000 24 | 🇺🇸 ME | UN_108021068 | true | 1789427245763 | 0 | 1786893780000 26 | 🇳🇱 ME | UN_108021068 | true | 1789427245763 | 0 | 1786893780000 ``` The new expiration timestamp: ```text 1789427245763 ``` corresponds to: ```text 2026-09-15 23:07:25.763 UTC ``` Therefore, on the master: * Inbounds 17, 20, 22, 24 and 26 contain the client with the **new expiration date**. * Inbound 44 does not contain the client anymore. * The `client_traffics` record 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: ```text id = 44 remark = 🇹🇷 ME enable = true ``` Query: ```sql SELECT id, remark, enable FROM inbounds WHERE id = 44; ``` Result: ```text id | remark | enable ----+--------+-------- 44 | 🇹🇷 ME | t ``` The inbound itself is enabled; the client is what has been removed/disabled. --- ## Node investigation The corresponding node inbound is: ```text id = 2 remark = 🇹🇷 ME ``` The node has only these inbounds: ```sql SELECT id, remark, enable, port, protocol FROM inbounds ORDER BY id; ``` Result: ```text id | remark | enable | port | protocol ----+--------+--------+------+---------- 2 | 🇹🇷 ME | t | 2087 | vmess 4 | 🇹🇷 HK | t | 2088 | vmess ``` The node's `settings` column is also `text` containing JSON: ```sql SELECT pg_typeof(settings) FROM inbounds WHERE id = 2; ``` Result: ```text pg_typeof ----------- text ``` The JSON structure contains the `clients` array: ```sql SELECT jsonb_object_keys(settings::jsonb) FROM inbounds WHERE id = 2; ``` Result: ```text jsonb_object_keys ------------------- clients ``` I then searched the node for the affected client: ```sql SELECT client ->> 'email' AS email, client ->> 'enable' AS enable, client ->> 'expiryTime' AS expiry_time, client ->> 'totalGB' AS total_gb, client ->> 'updated_at' AS updated_at FROM inbounds, jsonb_array_elements(settings::jsonb -> 'clients') AS client WHERE id = 2 AND client ->> 'email' = 'UN_108021068'; ``` Result: ```text email | enable | expiry_time | total_gb | updated_at -------+--------+-------------+----------+----------- (0 rows) ``` I also searched all node inbounds: ```sql SELECT id, remark, client ->> 'email' AS email, client ->> 'enable' AS enable, client ->> 'expiryTime' AS expiry_time, client ->> 'totalGB' AS total_gb, client ->> 'updated_at' AS updated_at FROM inbounds, jsonb_array_elements(settings::jsonb -> 'clients') AS client WHERE client ->> 'email' = 'UN_108021068' ORDER BY id; ``` Result: ```text (0 rows) ``` So at the time of investigation, `UN_108021068` was no longer present in the node's inbound configuration. --- ### 4. Node: client traffic Query: ```sql SELECT * FROM client_traffics WHERE email = 'UN_108021068'; ``` Result: ```text (0 rows) ``` Therefore the exact `UN_108021068` traffic record was also absent from the node. There is a different local record named `UN_108021068_2`: ```sql SELECT * FROM client_traffics WHERE email ILIKE '%UN_108021068%'; ``` Result: ```text id | inbound_id | enable | email | up | down | expiry_time | total | reset | last_online ----+------------+--------+------------------+-------+-------+---------------+-------+-------+---------------- 852 | 2 | t | UN_108021068_2 | 20108 | 46795 | 1789485822549 | 0 | 0 | 1786917273063 ``` 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: ```text 2026/08/16 15:28:43 DEBUG - X-UI: Client added onlocal:UN_108021068 2026/08/16 15:22:28 DEBUG - X-UI: Client added onlocal:UN_108021068 2026/08/16 09:08:14 DEBUG - X-UI: Client added onlocal:UN_108021068 ``` There were also previous client/inbound synchronization operations: ```text 2026/08/12 05:52:34 DEBUG - X-UI: Client edited onlocal:UN_108021068 2026/08/12 05:52:34 DEBUG - X-UI: Old client deleted onlocal:UN_108021068 2026/08/12 05:49:00 DEBUG - X-UI: Updated inbound added onlocal:in-2088-tcp 2026/08/12 05:49:00 DEBUG - X-UI: Old inbound deleted onlocal:in-2088-tcp 2026/08/12 05:48:59 DEBUG - X-UI: Client edited onlocal:UN_108021068 2026/08/12 05:48:59 DEBUG - X-UI: Old client deleted onlocal:UN_108021068 ``` 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: ```text 2026/08/16 20:45:54 INFO - X-UI: Remove Inbound User UN_108021068 due to expiration or traffic limit ``` 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: ```text Remove Inbound User [username] due to expiration or traffic limit ``` 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: 1. expired, 2. subsequently been extended, 3. received the new expiration date on other inbounds, 4. but an affected inbound/node can still retain stale expiration state and later remove the client. 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: 1. Create a client with an expiration date. 2. Allow the client to expire. 3. Extend the client after expiration. 4. The client receives the new expiration date on the main panel/other inbounds. 5. An affected node/inbound eventually removes the client. 6. The panel logs: ```text Remove Inbound User [email] due to expiration or traffic limit ``` 7. Detaching and reattaching the affected inbound restores the client temporarily. 8. The client can subsequently be removed again. ## 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 * 1 main/master panel * 3 nodes in the overall deployment * PostgreSQL * Multi-node configuration * Latest 3x-ui release at the time of reporting ## 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: ```text Remove Inbound User UN_108021068 due to expiration or traffic limit ``` 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: <img width="1769" height="77" alt="Image" src="https://github.com/user-attachments/assets/58d9219b-3c28-4d30-859b-e26cdc4eedcc" /> node : <img width="1769" height="77" alt="Image" src="https://github.com/user-attachments/assets/42d25c73-0e68-4247-886c-7c152a9303c6" /> ### 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 - [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:38:08 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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_traffics row, re-expiring an extended client panel-wide

Severity: High

Category: Correctness

Why this matters

client_traffics.email is declared gorm:"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:

  1. On every node poll (internal/web/job/node_traffic_sync_job.go:409), setRemoteTrafficLocked merges the node's client stats into that shared row. The expiry_time write at internal/web/service/inbound_node.go:898-915 adopts the node's value whenever it is positive:

    expiry_time = CASE WHEN expiry_time > 0 AND CAST(? AS BIGINT) <= 0
                       THEN expiry_time ELSE CAST(? AS BIGINT) END
    

    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 — no config_dirty guard on this statement. Any node still holding the pre-extension deadline writes it back over the extended one.

  2. The same merge runs SyncInbound for node-backed inbounds (inbound_node.go:1038), and applyClientRecordMerge overwrites the master's clients row fields outright — row.ExpiryTime = incoming.ExpiryTime and row.Enable = incoming.Enable at internal/web/service/client_link.go:58-59. Note that the same function computes max(incoming.UpdatedAt, row.UpdatedAt) at client_link.go:132, so it knows which side is newer but does not use that to decide the merge.

  3. The depletion check then runs in the same tick (node_traffic_sync_job.go:134 → AddTraffic). depletedClientsCondLocal is (total > 0 AND up + down >= total) OR (expiry_time > 0 AND expiry_time <= ?) (internal/web/service/inbound_disable.go:60-61). With total = 0 only the expiry branch can match — consistent with your observation that this is not a quota case. disableInvalidClients then sets clients.enable = false for that email with WHERE email IN ? (inbound_disable.go:172-178), i.e. on every inbound, not just the one that reported stale.

  4. Config generation drops the client and emits precisely your log line at internal/web/service/xray.go:196-199, keyed only on client_traffics.enable.

Two things make it self-sustaining rather than a one-off:

  • The enable merge is one-way. ClientTrafficEnableMergeExpr is CASE WHEN <node enable> THEN enable ELSE false END (internal/database/dialect.go:40-45): a node reporting enable=false switches the master row off, but a node reporting enable=true can 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.
  • For a node-backed inbound the master adopts the node's settings JSON 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.Update iterates 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, UpdateInboundClient fails it with empty 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/enable adoption on the master's own clients.updated_at for that email, so a snapshot older than the last master-side edit cannot roll the deadline back — and skip the adoption entirely while config_dirty is set, matching the guard already applied to the settings adoption a few lines above. Scoping disableInvalidClients' clients.enable = false write so one inbound's stale row cannot disable the email on all of them would limit the blast radius as well.

Example

internal/web/service/inbound_node.go:898-915  (setRemoteTrafficLocked)
  UPDATE client_traffics SET ... expiry_time = CASE WHEN expiry_time > 0 AND ? <= 0
    THEN expiry_time ELSE ? END ... WHERE email = ?
  -> node value wins whenever positive; no master-newer check, no `dirty` guard
internal/web/service/client_link.go:58-59     (applyClientRecordMerge)
  row.ExpiryTime = incoming.ExpiryTime; row.Enable = incoming.Enable

Confidence: high for the mechanism above (every step is read from the source and matches your row exactly: enable = f, old expiry_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:

  1. On the master: 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.
  2. On the master: SELECT id, email, enable, expiry_time, updated_at FROM clients WHERE email = 'UN_108021068'; — the clients table is authoritative; the settings JSON you queried is a denormalized copy.
  3. On each of the three nodes: SELECT email, enable, expiry_time, total FROM client_traffics WHERE email = 'UN_108021068'; — one of them should still hold 1786835245763.
  4. Panel log lines from the master around 20:45:54 containing setRemoteTraffic or Error in updating client on.
  5. The x-ui version 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, 1789427245763 converts to 2026-09-14 23:07:25 UTC rather than the 2026-09-15 in 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.

<!-- gh-comment-id:5310024958 --> @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_traffics` row, re-expiring an extended client panel-wide Severity: High Category: Correctness Why this matters `client_traffics.email` is declared `gorm:"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: 1. On every node poll (`internal/web/job/node_traffic_sync_job.go:409`), `setRemoteTrafficLocked` merges the node's client stats into that shared row. The `expiry_time` write at `internal/web/service/inbound_node.go:898-915` adopts the node's value whenever it is positive: ```sql expiry_time = CASE WHEN expiry_time > 0 AND CAST(? AS BIGINT) <= 0 THEN expiry_time ELSE CAST(? AS BIGINT) END ``` 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` — no `config_dirty` guard on this statement. Any node still holding the pre-extension deadline writes it back over the extended one. 2. The same merge runs `SyncInbound` for node-backed inbounds (`inbound_node.go:1038`), and `applyClientRecordMerge` overwrites the master's `clients` row fields outright — `row.ExpiryTime = incoming.ExpiryTime` and `row.Enable = incoming.Enable` at `internal/web/service/client_link.go:58-59`. Note that the same function computes `max(incoming.UpdatedAt, row.UpdatedAt)` at `client_link.go:132`, so it knows which side is newer but does not use that to decide the merge. 3. The depletion check then runs in the same tick (`node_traffic_sync_job.go:134` → `AddTraffic`). `depletedClientsCondLocal` is `(total > 0 AND up + down >= total) OR (expiry_time > 0 AND expiry_time <= ?)` (`internal/web/service/inbound_disable.go:60-61`). With `total = 0` only the expiry branch can match — consistent with your observation that this is not a quota case. `disableInvalidClients` then sets `clients.enable = false` for that email with `WHERE email IN ?` (`inbound_disable.go:172-178`), i.e. on **every** inbound, not just the one that reported stale. 4. Config generation drops the client and emits precisely your log line at `internal/web/service/xray.go:196-199`, keyed only on `client_traffics.enable`. Two things make it self-sustaining rather than a one-off: - The enable merge is one-way. `ClientTrafficEnableMergeExpr` is `CASE WHEN <node enable> THEN enable ELSE false END` (`internal/database/dialect.go:40-45`): a node reporting `enable=false` switches the master row off, but a node reporting `enable=true` can 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. - For a node-backed inbound the master adopts the node's `settings` JSON 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.Update` iterates 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, `UpdateInboundClient` fails it with `empty 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`/`enable` adoption on the master's own `clients.updated_at` for that email, so a snapshot older than the last master-side edit cannot roll the deadline back — and skip the adoption entirely while `config_dirty` is set, matching the guard already applied to the settings adoption a few lines above. Scoping `disableInvalidClients`' `clients.enable = false` write so one inbound's stale row cannot disable the email on all of them would limit the blast radius as well. Example ``` internal/web/service/inbound_node.go:898-915 (setRemoteTrafficLocked) UPDATE client_traffics SET ... expiry_time = CASE WHEN expiry_time > 0 AND ? <= 0 THEN expiry_time ELSE ? END ... WHERE email = ? -> node value wins whenever positive; no master-newer check, no `dirty` guard internal/web/service/client_link.go:58-59 (applyClientRecordMerge) row.ExpiryTime = incoming.ExpiryTime; row.Enable = incoming.Enable ``` Confidence: high for the mechanism above (every step is read from the source and matches your row exactly: `enable = f`, old `expiry_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: 1. On the master: `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. 2. On the master: `SELECT id, email, enable, expiry_time, updated_at FROM clients WHERE email = 'UN_108021068';` — the `clients` table is authoritative; the `settings` JSON you queried is a denormalized copy. 3. On **each** of the three nodes: `SELECT email, enable, expiry_time, total FROM client_traffics WHERE email = 'UN_108021068';` — one of them should still hold `1786835245763`. 4. Panel log lines from the master around `20:45:54` containing `setRemoteTraffic` or `Error in updating client on`. 5. The `x-ui` version 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, `1789427245763` converts to `2026-09-14 23:07:25 UTC` rather than the `2026-09-15` in 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.*
Author
Owner

@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

<!-- gh-comment-id:5310060872 --> @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
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#4230
No description provided.