[PR #6284] [MERGED] fix(node): don't stamp InboundsAdoptedAt when the sync adopted nothing #6209

Closed
opened 2026-11-02 04:07:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6284
Author: @yzxcj797
Created: 8/22/2026
Status: ✅ Merged
Merged: 8/22/2026
Merged by: @MHSanaei

Base: main ← Head: fix/empty-tags-false-adoption-6283


📝 Commits (3)

  • 4771733 fix(node): don't stamp InboundsAdoptedAt when the sync adopted nothing
  • 9bb0049 restore atomicBool tests; trim comment to repo 2-line cap
  • 21e585e trim syncCanAdopt comment to the 2-line cap

📊 Changes

2 files changed (+54 additions, -1 deletions)

View changed files

📝 internal/web/job/node_traffic_sync_job.go (+11 -1)
📝 internal/web/job/node_traffic_sync_job_test.go (+43 -0)

📄 Description

Fixes #6283.

Root cause

syncOne stamps InboundsAdoptedAt on any clean sync, but in selected mode with an empty tag list the snapshot is emptied by FilterNodeSnapshot before SetRemoteTraffic sees it — the sync adopts nothing, the flag is stamped anyway, and the reconcile sweep (gated on the flag since 200ea091, the fix for #5898) then treats the node's unadopted pre-existing inbounds as "deleted locally" and removes them. Registering a working node first and choosing tags afterwards — the natural safe order — destroys the node's inbounds, exactly as the issue's state table shows.

Fix

Gate the stamp on the sync actually being able to adopt: the new syncCanAdoptInbounds(n, adoptedAliases) requires, in selected mode, at least one selected tag or adopted alias (both are admitted by the snapshot filter); other modes always adopt. The natural follow-up sync — after the operator selects tags — then performs the real first adoption and stamps the flag correctly.

Test

TestSyncCanAdoptInbounds (table-driven): all mode adopts; selected+tags adopts; selected-empty+alias adopts; selected-empty+no-aliases adopts nothing (the reported bug). Both internal/web/service and internal/web/job packages pass their full suites.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6284 **Author:** [@yzxcj797](https://github.com/yzxcj797) **Created:** 8/22/2026 **Status:** ✅ Merged **Merged:** 8/22/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/empty-tags-false-adoption-6283` --- ### 📝 Commits (3) - [`4771733`](https://github.com/MHSanaei/3x-ui/commit/4771733f42e74f4a998dfdf369993ca3ea3e9d78) fix(node): don't stamp InboundsAdoptedAt when the sync adopted nothing - [`9bb0049`](https://github.com/MHSanaei/3x-ui/commit/9bb00496d37bac8553c1650cee7f2380722a89cd) restore atomicBool tests; trim comment to repo 2-line cap - [`21e585e`](https://github.com/MHSanaei/3x-ui/commit/21e585e8ffbecbf3cc4f9a206d7fc8e036c5a040) trim syncCanAdopt comment to the 2-line cap ### 📊 Changes **2 files changed** (+54 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/job/node_traffic_sync_job.go` (+11 -1) 📝 `internal/web/job/node_traffic_sync_job_test.go` (+43 -0) </details> ### 📄 Description Fixes #6283. ## Root cause `syncOne` stamps `InboundsAdoptedAt` on any clean sync, but in **selected mode with an empty tag list** the snapshot is emptied by `FilterNodeSnapshot` before `SetRemoteTraffic` sees it — the sync adopts nothing, the flag is stamped anyway, and the reconcile sweep (gated on the flag since `200ea091`, the fix for #5898) then treats the node's unadopted pre-existing inbounds as "deleted locally" and removes them. Registering a working node first and choosing tags afterwards — the natural safe order — destroys the node's inbounds, exactly as the issue's state table shows. ## Fix Gate the stamp on the sync actually being able to adopt: the new `syncCanAdoptInbounds(n, adoptedAliases)` requires, in selected mode, at least one selected tag **or** adopted alias (both are admitted by the snapshot filter); other modes always adopt. The natural follow-up sync — after the operator selects tags — then performs the real first adoption and stamps the flag correctly. ## Test `TestSyncCanAdoptInbounds` (table-driven): all mode adopts; selected+tags adopts; selected-empty+alias adopts; **selected-empty+no-aliases adopts nothing** (the reported bug). Both `internal/web/service` and `internal/web/job` packages pass their full suites. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:07 +07:00
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#6209
No description provided.