Skip to content

Commit b84c347

Browse files
committed
fix(node): handle default core config and refresh cache before sync
- Update node query to include nodes with null core_config_id when filtering by core_id=1 - Add cache refresh before syncing node users to prevent stale core/inbound configuration races - Ensures default core configuration is properly included in node queries - Prevents race conditions between cache updates and user synchronization
1 parent 43a3d0c commit b84c347

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

app/db/crud/node.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ async def get_nodes(
116116
stmt = stmt.where(Node.status.not_in([NodeStatus.disabled, NodeStatus.limited]))
117117

118118
if params.core_id:
119-
stmt = stmt.where(Node.core_config_id == params.core_id)
119+
if params.core_id == 1:
120+
stmt = stmt.where(or_(Node.core_config_id == params.core_id, Node.core_config_id.is_(None)))
121+
else:
122+
stmt = stmt.where(Node.core_config_id == params.core_id)
120123

121124
if params.ids:
122125
stmt = stmt.where(Node.id.in_(params.ids))

app/node/worker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ async def _sync_node_users(self, data: dict):
202202
flush_users = data.get("flush_users", False)
203203
if not node_id:
204204
return
205+
# Refresh from KV before syncing to avoid stale core/inbound cache races.
206+
await core_manager._reload_from_cache()
205207
async with GetDB() as db:
206208
await self._node_operator.sync_node_users(db, node_id=node_id, flush_users=flush_users)
207209

0 commit comments

Comments
 (0)