Skip to content

fix: load device info when server is updating - #985

Draft
dengzhongyuan365-dev wants to merge 1 commit into
linuxdeepin:masterfrom
dengzhongyuan365-dev:agent/bugfix/378099
Draft

dengzhongyuan365-dev wants to merge 1 commit into
linuxdeepin:masterfrom
dengzhongyuan365-dev:agent/bugfix/378099

Conversation

@dengzhongyuan365-dev

@dengzhongyuan365-dev dengzhongyuan365-dev commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Root Cause Analysis

When the device manager is reopened while the backend server is updating (up to 60s), LoadInfoThread::run() checks is_server_running via DBus. If it returns "1" (updating), the else branch completely skips data loading and directly emits finished("finish"), leaving DeviceManager empty — so the UI shows incomplete device info. This triggers when: first open loads data → triggers refreshDataBaseLater() → server starts updating → user closes & reopens → is_server_running=1 → skip loading → empty UI.

Fix

Replace the skip-when-server-running logic with a polling loop: when is_server_running returns "1", poll every 500ms (with a 30s timeout) until the server finishes updating, then proceed with normal data loading. On timeout, fall back to loading with current data as a safety net. The else branch ("do nothing") is removed entirely — data loading now runs unconditionally after the polling check.

Change Safety Assessment

Code Safety

  • Risk Level: Medium
  • Target function LoadInfoThread::run() internal logic change — no signature change, no new public interface
  • The else branch (skip loading) was original design from commit d44d9ac9, not a prior bug fix product — this change does not revert any historical fix
  • Existing unit test UT_LoadInfoThread::Run_ServerRunning_SkipsHeavyPath covers this behavior path and will need updating to reflect new behavior (pending user decision)

Business Impact Scope

  • Device info loading: All scenarios where device manager is opened while backend server is updating
  • Affected callers: LoadInfoThread::run(), MainWindow::slotLoadingFinish()
  • User scenario: After multiple opens of device manager, device info now displays completely every time; max 30s delay when server is actively updating

Verification Suggestion

  1. Test reopening device manager while server is updating — verify info displays completely
  2. Test multiple open/close cycles — verify no info loss
  3. Test app shutdown during polling — verify no hang

根因分析

当设备管理器在后端服务正在更新时(最长 60 秒)被重新打开,LoadInfoThread::run() 通过 DBus 检查 is_server_running。如果返回 "1"(正在更新),else 分支完全跳过数据加载,直接发射 finished("finish") 信号,导致 DeviceManager 为空——因此 UI 显示不全。触发链路:首次打开加载数据 → 触发 refreshDataBaseLater() → 服务端开始更新 → 用户关闭再打开 → is_server_running=1 → 跳过加载 → UI 为空。

修复方案

将"服务端运行时跳过"逻辑替换为轮询等待:当 is_server_running 返回 "1" 时,每 500ms 轮询一次(30 秒超时),等待服务端更新完成后执行正常数据加载。超时后降级为本地加载作为兜底。else 分支("do nothing")被完全移除——数据加载现在在轮询检查后无条件执行。

改动安全评估

代码安全评估

  • 风险等级: 中风险
  • 目标函数 LoadInfoThread::run() 内部逻辑改动——不改签名、不新增公开接口
  • else 分支(跳过加载)是 commit d44d9ac9 的原始设计,非历史 bug 修复产物——本次改动不撤销任何历史修复
  • 既有单测 UT_LoadInfoThread::Run_ServerRunning_SkipsHeavyPath 覆盖该行为路径,需更新以反映新行为(待用户决定)

业务影响范围

  • 设备信息加载:设备管理器在服务端更新期间被打开的所有场景
  • 受影响调用方:LoadInfoThread::run()、MainWindow::slotLoadingFinish()
  • 用户场景:多次打开设备管理器后,设备信息每次均完整显示;服务端更新期间最多延迟 30 秒

验证建议

  1. 测试服务端更新时重新打开设备管理器——验证信息完整显示
  2. 测试多次打开关闭——验证无信息丢失
  3. 测试轮询期间关闭应用——验证无挂起

Summary by Sourcery

Load device information reliably while the backend server is updating.

Bug Fixes:

  • Ensure device information is loaded when the backend server is updating by waiting for completion and using current data as a timeout fallback.

Tests:

  • Update LoadInfoThread tests to validate loading after polling timeout and prevent polling-related test hangs.

1. Root cause: LoadInfoThread::run() skipped data loading entirely
   when is_server_running returned "1", leaving DeviceManager empty
2. Fix: replace skip with polling loop (500ms interval, 30s timeout)
   that waits for server update to finish, then loads data normally
3. Impact: device info always loads regardless of server state; max
   30s delay when server is updating, with fallback load on timeout

Log: Fixed incomplete device info after reopening device manager

Influence:
1. Test reopening device manager while server is updating
2. Verify device info displays completely after multiple opens
3. Test app shutdown during server update polling (no hang)

fix: 服务端更新时加载设备信息

1. 根因:LoadInfoThread::run() 在 is_server_running 返回 "1" 时完全
   跳过数据加载,导致 DeviceManager 为空,信息显示不全
2. 方案:将跳过改为轮询等待(500ms 间隔,30s 超时),等待服务端更新
   完成后正常加载数据;超时后仍执行本地加载作为兜底
3. 影响:设备信息始终加载,不再因服务端状态跳过;服务端更新期间
   最多延迟 30s,超时后降级加载

Log: 修复多次打开设备管理器后信息显示不全的问题

Influence:
1. 测试服务端更新时重新打开设备管理器
2. 验证多次打开后设备信息完整显示
3. 测试轮询等待期间关闭应用(无挂起)

PMS: BUG-378099
@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Poll the backend while it is updating, then run the existing data-loading path unconditionally, with a 30-second timeout fallback.

  • deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp L65-81, L138 (removed lines)

Tests

Update the server-running test to expect loading after the polling timeout and stub the clock for deterministic execution.

  • test/deepin-devicemanager/src/GenerateDevice/ut_loadinfothread.cpp L258-328 (4 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-bot

deepin-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.77
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #990

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants