[GH-ISSUE #5571] [Question]: “Old users’ usage volume is not syncing.” #3890

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

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

What are you trying to do?

“I have a server that had a panel and users on it. I turned it into a node connected to a main server, and the inbound and users got synced. But the users’ usage volume on the main server started from zero.
So basically it brought the users and synced them on the main server, but it didn’t bring their consumed traffic/usage. For example, if a user had 30 GB usage on the node server, on the main server it started from zero again.”

من یه سرور دارم که روش پنل و یوزر بود کردمش نود یه سرور اصلی و اینباند و یوزرش سینک شد
.ولی حجم مصرفیش رو سرور مادر از صفر شروع شده

ینی خود یوزر رو آورد سینک کرد رو سرور مادر ولی حجم مصرفیش رو نیاورد
مثلا اگه روی سرور نود کاربر ۳۰ گیگ مصرفش بود ٫
روی سرور مادر شروع کرد از صفر

Image Image

What have you already tried?

No response

3x-ui version

3.4.0

How did you install 3x-ui?

install.sh script

Operating system

No response

Screenshots or config snippets

No response

Before submitting

  • I read the Wiki and searched existing issues.
  • This is a usage question, not a bug report.
  • This question is written in English.
Originally created by @Shm9220 on GitHub (Jun 25, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5571 ### What are you trying to do? “I have a server that had a panel and users on it. I turned it into a node connected to a main server, and the inbound and users got synced. But the users’ usage volume on the main server started from zero. So basically it brought the users and synced them on the main server, but it didn’t bring their consumed traffic/usage. For example, if a user had 30 GB usage on the node server, on the main server it started from zero again.” من یه سرور دارم که روش پنل و یوزر بود کردمش نود یه سرور اصلی و اینباند و یوزرش سینک شد .ولی حجم مصرفیش رو سرور مادر از صفر شروع شده ینی خود یوزر رو آورد سینک کرد رو سرور مادر ولی حجم مصرفیش رو نیاورد مثلا اگه روی سرور نود کاربر ۳۰ گیگ مصرفش بود ٫ روی سرور مادر شروع کرد از صفر <img width="381" height="259" alt="Image" src="https://github.com/user-attachments/assets/28640bf0-6b87-4fdb-b69f-5eebd4f8b6dc" /> <img width="480" height="271" alt="Image" src="https://github.com/user-attachments/assets/44a348cd-ad16-45f5-aba0-9d31d6c564e5" /> ### What have you already tried? _No response_ ### 3x-ui version 3.4.0 ### How did you install 3x-ui? install.sh script ### Operating system _No response_ ### Screenshots or config snippets _No response_ ### Before submitting - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
bsakaguchi 2026-10-31 20:35:41 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 25, 2026):

The behavior you are seeing is intentional. When a server that already has clients and traffic history is joined to a main panel as a node, the main panel initializes each client's traffic counter at zero on the first sync and records the node's current cumulative counter as a baseline in the node_client_traffics table. Only traffic accumulated after that first sync is credited on the main panel.

This is confirmed directly in the source:

  • internal/web/service/inbound_node.go, lines 619–646 (setRemoteTrafficLocked): when a client email is seen for the first time on a node, a new client_traffics row is created with Up: 0, Down: 0, and upsertNodeBaseline stores the node's current counter as the starting point.
  • internal/web/service/node_client_traffic_sum_test.go, line 100: the test explicitly asserts 0, 0 after the first sync with the comment "after baselines — historical node traffic not imported".

Subsequent syncs compute delta = current_node_counter − baseline and add only that increment to the main panel's counter. The design avoids false inflation from stale counters (for example, a client deleted on the main panel but still tracked on the node).

There is no built-in mechanism to import pre-node historical traffic. If you need those accumulated totals to appear on the main panel, the only option is a direct database edit:

  1. Back up the main panel's database first:
    cp /etc/x-ui/x-ui.db /etc/x-ui/x-ui.db.bak
    
  2. Open the database:
    sqlite3 /etc/x-ui/x-ui.db
    
  3. For each client, add the historical amounts to the existing counters:
    UPDATE client_traffics
    SET up   = up   + <historical_upload_bytes>,
        down = down + <historical_download_bytes>
    WHERE email = '<client_email>';
    

If the main panel uses PostgreSQL (XUI_DB_TYPE=postgres), the same UPDATE query applies against that database instead.

This direct database edit is not supported through the panel UI and should be done with care.


رفتاری که مشاهده می‌کنید طراحی‌شده و عمدی است. وقتی یک سرور مستقل که کاربران و ترافیک دارد به‌عنوان نود به پنل اصلی اضافه می‌شود، در اولین سینک، پنل اصلی مقدار مصرف هر کاربر را از صفر شروع می‌کند و مقدار فعلی شمارنده ترافیک نود را به‌عنوان پایه (baseline) ذخیره می‌کند. فقط ترافیکی که بعد از اولین سینک مصرف شود در پنل اصلی حساب می‌شود.

این رفتار در کد منبع (internal/web/service/inbound_node.go، خطوط ۶۱۹–۶۴۶) تأیید شده است و یک تصمیم طراحی آگاهانه است تا از ثبت اشتباه ترافیک‌های قدیمی یا حذف‌شده جلوگیری شود.

برای اضافه‌کردن دستی ترافیک تاریخی، تنها راه ویرایش مستقیم جدول client_traffics در پایگاه‌داده پنل اصلی است (دستورات بالا). پیش از هر تغییری از فایل x-ui.db نسخه پشتیبان تهیه کنید.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4802775120 --> @github-actions[bot] commented on GitHub (Jun 25, 2026): The behavior you are seeing is intentional. When a server that already has clients and traffic history is joined to a main panel as a node, the main panel initializes each client's traffic counter at zero on the first sync and records the node's current cumulative counter as a baseline in the `node_client_traffics` table. Only traffic accumulated **after** that first sync is credited on the main panel. This is confirmed directly in the source: - `internal/web/service/inbound_node.go`, lines 619–646 (`setRemoteTrafficLocked`): when a client email is seen for the first time on a node, a new `client_traffics` row is created with `Up: 0, Down: 0`, and `upsertNodeBaseline` stores the node's current counter as the starting point. - `internal/web/service/node_client_traffic_sum_test.go`, line 100: the test explicitly asserts `0, 0` after the first sync with the comment `"after baselines — historical node traffic not imported"`. Subsequent syncs compute `delta = current_node_counter − baseline` and add only that increment to the main panel's counter. The design avoids false inflation from stale counters (for example, a client deleted on the main panel but still tracked on the node). **There is no built-in mechanism to import pre-node historical traffic.** If you need those accumulated totals to appear on the main panel, the only option is a direct database edit: 1. Back up the main panel's database first: ```bash cp /etc/x-ui/x-ui.db /etc/x-ui/x-ui.db.bak ``` 2. Open the database: ```bash sqlite3 /etc/x-ui/x-ui.db ``` 3. For each client, add the historical amounts to the existing counters: ```sql UPDATE client_traffics SET up = up + <historical_upload_bytes>, down = down + <historical_download_bytes> WHERE email = '<client_email>'; ``` If the main panel uses PostgreSQL (`XUI_DB_TYPE=postgres`), the same `UPDATE` query applies against that database instead. This direct database edit is not supported through the panel UI and should be done with care. --- رفتاری که مشاهده می‌کنید طراحی‌شده و عمدی است. وقتی یک سرور مستقل که کاربران و ترافیک دارد به‌عنوان نود به پنل اصلی اضافه می‌شود، در اولین سینک، پنل اصلی مقدار مصرف هر کاربر را از صفر شروع می‌کند و مقدار فعلی شمارنده ترافیک نود را به‌عنوان پایه (baseline) ذخیره می‌کند. فقط ترافیکی که **بعد** از اولین سینک مصرف شود در پنل اصلی حساب می‌شود. این رفتار در کد منبع (`internal/web/service/inbound_node.go`، خطوط ۶۱۹–۶۴۶) تأیید شده است و یک تصمیم طراحی آگاهانه است تا از ثبت اشتباه ترافیک‌های قدیمی یا حذف‌شده جلوگیری شود. برای اضافه‌کردن دستی ترافیک تاریخی، تنها راه ویرایش مستقیم جدول `client_traffics` در پایگاه‌داده پنل اصلی است (دستورات بالا). پیش از هر تغییری از فایل `x-ui.db` نسخه پشتیبان تهیه کنید. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jun 25, 2026):

b32837e523

<!-- gh-comment-id:4803407224 --> @MHSanaei commented on GitHub (Jun 25, 2026): b32837e523421fa6bf6158be518863d38f65f95a
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#3890
No description provided.