Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
315d2e85b3 |
No files matched your search
@@ -1,36 +0,0 @@
|
||||
# 工单 #33 根因分析与 1.3.3 本地预验收
|
||||
|
||||
现场基线为 Windows 便携版 1.3.2,修复基线为 main 的 46deb9c。原始交付包 SHA-256 为 `1ac99eac3cf79bbf1f011d1d5fe833e92b98fba2c01546b3cfaf55a90b82d5b3`,本地逐项复核包内清单的 4,469 个文件全部一致。[工单与附件](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/issues/33)
|
||||
|
||||
## 原始记录还原
|
||||
|
||||
1. 在 `05_实测证据/data_full132/task-queues/55e1032ac965453b8adf307da1400511.json` 中,100 项分为 6 completed、3 skipped、2 blocked、89 pending。任务列表中的 92 draft 包含了队列已跳过的三项。09:30:17 的监控显示第 11 项 BOB_Shield 在做替换前快照,09:32:18 显示资源待清理。
|
||||
2. 首批在第 10 项 BOB 的第 23 个操作和第 11 项 BOB_Shield 的第 18 个操作加载 `4885-S033D0-M220` 超时,各自的 native.json 均标记 preflight。第 10 项已写入 isolated_tasks,并实际派发了第 11 项。第 11 项仅写入 blocked。不能把整批归因于“遇到第一个失败就停”。另一个 91 项检查点记录了 WiFi 工程加载 `4885-S018D0-M220` 超时。工具报告的空窗口与这个超时属于不同 generation,尚不能认定窗口引起该次超时。
|
||||
3. 首批资源目录 `1d5d999ec63045b49661466928de9a01` 的 business-result.json 报 paused=true,current_task_id 对应 BOB_Shield。supervisor.json 的 finished 描述监督器退出。session.json 的最终状态是 isolated、blocking=false、mentor_released=true、desktop_released=false。任务隔离、队列暂停、监督器退出、资源是否可再租用分别有自己的证据。后续批次另有 blocking=true 的记录。现场没有足够证据指认持有桌面句柄的外部进程。
|
||||
|
||||
## 单项修复和判据
|
||||
|
||||
| 项 | 已定位的入口或失效条件 | 修改与本地复验 |
|
||||
|---|---|---|
|
||||
| D2 路径错误 | 工程根校验和扫描后登记有不同失败窗口,文件系统异常落到通用错误提示 | 分别注入目录不存在、选择了普通文件、扫描后移走、访问被拒;检查 GUI 中路径、码、修复建议,日志按同类输入统计兜底数并保留真正未知异常的诊断 |
|
||||
| D1 同根双开 | 单工程和队列执行锁在主窗口启动后才生效,两个 GUI 可先打开同一数据库并启动恢复 | 在首次打开数据库之前取得 data-root 级互斥;4 个进程同时打开同根,再试异根、helper 和持有者异常退出,检查持有者 PID、唤醒回执、应用启动次数以及原任务 ID |
|
||||
| D6 原生加载 | 需区分本次加载尚未点击写入与前序位号已暂存。当前预读不能证明整个工程仍无修改;列表控件刷新也可能令旧 HWND 失效 | 使用工程副本分别注入首次/热加载、列表重建、超时前已写/未写、不同 owner 的空弹窗。记录 attempt/generation、写前标记、前后属性、关闭与保存回执。仅在本项未写且身份可证时有限重试;写入可能性跨重启必须保留 |
|
||||
| D7 资源收尾 | 一条历史隔离回执已经可以不拦下一批;同名桌面、租约归还及对象物理消失有不同寿命 | 对照正常关闭、带窗口的自有 writer、仅有外部 OpenDesktop 句柄、证据缺失四组。按 PID 和创建时间确认自有进程退出、关闭自有句柄、重新枚举,再以有界退避重查。外部持有期间不得记 released;外部释放后应自动收敛。记录旧租约与新租约,禁止旧代清理新 owner |
|
||||
| D8 整批停顿 | 第一个不确定工程已被隔离,第二个未获得同等隔离结果;队列持久化暂停后,资源提示变成可用也未推进原队列 | 基于已验收的 D7 结果复验两次连续失败,区分同写源与无关工程、主动暂停与故障等待。只恢复原队列、原计划、未派发项;活 writer、未知归属或同写源仍隔离。比对操作 ID、保存次数、所有任务终态和 UI 文案 |
|
||||
| D5 BOM 列 | 表头映射只读取已知列;“失败 0 行”无法告知额外列未采用 | 实际导入现场 B3 工作簿,再导入带两列、近义列、缺列、重复列、公式和标准模板。额外列一次列出并提示近义列,核对预览、保存结果和持久化规则 |
|
||||
| D3 窗口 | ui-layout.ini 保存分栏和排序,主窗口仍用默认尺寸 | 从真实主窗口调整大小、位置和最大化后退出重启,测 125% 缩放与失去屏幕后的可见区域;损坏 ini 应可启动 |
|
||||
| D4 零结果 | TaskList._render 只更新列表和数值,缺少对空列表原因的呈现 | 用 Qt 键盘输入现场关键词 zzzz_no_match,切换筛选、组合搜索、回收站和空库,清除条件后验证原集合及选择;核对实际显示的关键词、筛选名与匹配数 |
|
||||
|
||||
## 分层复跑与交付口径
|
||||
|
||||
本机复跑以下两条基线命令,分别校验现场原件和生产调度器。第二条使用真实 SQLite、BOM 读取、任务队列及检查点,CAD 执行由夹具驱动。得到 99 completed、1 blocked、199 次操作,耗时 608.3 秒。这个单故障场景在修复前已能跑完,因此不能用它单独验收 D8。
|
||||
|
||||
```powershell
|
||||
python tools/inspect_issue33_field.py G:/dx33/acceptance/field.zip
|
||||
python tools/measure_task_queue.py --projects 100 --sheets 1 --rules 1 --behavior uncertain_stop --output build/issue33-baseline100
|
||||
```
|
||||
|
||||
- **本地预验收**使用独立 data-root 和工程副本。每项记录软件提交、输入、触发步骤、期望/实际结果、日志和可复跑命令。重启测试复用同一测试根。验证命令和结果随各单项 PR 提交。工单指定 D6、D7、D8 按序合入,不能用其他批次的通过报告替代当前批次。
|
||||
- **整批故障注入**先跑 8 项混合队列,再跑 100 工程固定顺序。对第 10、11 项连续注入现场两种失败,独立工程继续,另设一个共享 iCDB 的依赖工程以验证隔离。第 23 个位号前后分别中断,复用同一 queue_id 两次重启,逐项比较 saved 的操作 ID 与次数。未知写入不能计入成功。
|
||||
- **现场复测**用发行候选包与六套固定试卷逐题执行。卷六的暂停、重启、不重放和下一批启动优先。验收要求卷四、六各至少 80 分,总分至少 500/600,六卷无 P0 复发。正常批次检查 uncertain.flag=0,收尾核对桌面枚举与活进程。如仅运行夹具或源码,报告应标明该范围并单列真实 Mentor、现场库、物理副屏等待测项。
|
||||
- 本地采集目录为 `G:/dx33/acceptance`。现场 ZIP 留存原样,复验使用副本。原始打分仍是 373/600;菜单驱动、多选自动化和模型端点限流单列,分数只随实际复跑更新。
|
||||
@@ -0,0 +1,17 @@
|
||||
# Issue #33 D1 同数据目录单实例
|
||||
|
||||
`application.main` 原先直接配置日志、打开 `task-center.db` 并执行启动恢复。现场 `data_lock` 日志有两次同根 `application_start`,两实例均成功读取任务列表。现有执行租约只在执行操作中生效。
|
||||
|
||||
GUI 现在先取得 `.gui-instance.lock` 的内核文件锁,再打开日志和数据库。第二次启动经 Qt 本地套接字请求激活现有窗口,该窗口写入 `instance_conflict` 并在状态栏提示。锁保持到 SQLite 和后台读线程关闭,进程强制结束时由操作系统回收。启动参数中的工作进程和 CLI 在 GUI 文件锁之前分流。
|
||||
|
||||
## Windows 复测
|
||||
|
||||
```powershell
|
||||
$env:QT_QPA_PLATFORM = 'offscreen'
|
||||
python -m pytest -q tests/v1_1/test_single_instance.py
|
||||
```
|
||||
|
||||
- 四个真实 GUI 子进程并发打开同一目录,其中两个使用大写路径。日志有一次 `application_start`、一次启动恢复和三次 `instance_conflict`,三个转发进程均返回 0。
|
||||
- 另一个数据目录的窗口与持锁窗口同时存活。同根 `--native-helper` 执行自身参数校验并返回 2,冲突计数仍为三次。
|
||||
- 强制结束持锁进程后,同根 `--smoke-test` 成功启动并正常关闭,预先写入的任务 ID 仍在 SQLite。另一数据目录的进程继续运行。
|
||||
- 修改前运行同一并发场景时,三个竞争进程没有退出,测试失败。测试使用 Qt offscreen,验证激活请求已处理。Windows 桌面前台切换和实际 CAD 写入需通过交互式验收复核。
|
||||
@@ -9,12 +9,13 @@ import platform
|
||||
import sys
|
||||
from typing import Sequence
|
||||
|
||||
from PySide6.QtCore import QTimer, QThreadPool
|
||||
from PySide6.QtCore import QTimer, QThreadPool, Qt
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from dx_productivity.trial_task_center.logging_setup import LoggingContext, configure_logging, install_exception_hooks
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.single_instance import InstanceUnavailable, gui_instance, listen_for_activation
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.version import VERSION
|
||||
|
||||
@@ -161,10 +162,28 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
from dx_productivity.trial_task_center.sceneos_cli import run
|
||||
|
||||
return run(data_root)
|
||||
try:
|
||||
with gui_instance(data_root) as endpoint:
|
||||
if endpoint is None:
|
||||
return 0
|
||||
return _run_gui(argv, arguments, data_root, endpoint)
|
||||
except (OSError, InstanceUnavailable) as error:
|
||||
message = f'无法打开 DxPartReplace。\n{data_root}\n{error}'
|
||||
if sys.stderr is not None:
|
||||
print(message, file=sys.stderr)
|
||||
if os.name == 'nt' and bool(getattr(sys, 'frozen', False)):
|
||||
import ctypes
|
||||
|
||||
ctypes.windll.user32.MessageBoxW(None, message, 'DxPartReplace', 0x30)
|
||||
return 1
|
||||
|
||||
|
||||
def _run_gui(argv, arguments, data_root, endpoint):
|
||||
logging_context = configure_logging(data_root)
|
||||
install_exception_hooks(logging_context)
|
||||
store: TaskStore | None = None
|
||||
window = None
|
||||
activation_server = None
|
||||
try:
|
||||
database_path = data_root / "task-center.db"
|
||||
_log_startup(logging_context, data_root, database_path)
|
||||
@@ -177,6 +196,16 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
configure_application_identity(qt_application)
|
||||
window = _load_window()(service)
|
||||
window.show()
|
||||
|
||||
def activate():
|
||||
logging_context.logger.info('instance_conflict data_root=%s', data_root)
|
||||
window.setWindowState(window.windowState() & ~Qt.WindowState.WindowMinimized)
|
||||
window.show()
|
||||
window.raise_()
|
||||
window.activateWindow()
|
||||
window.statusBar().showMessage('此数据目录已在使用,已切换到现有窗口。', 6000)
|
||||
|
||||
activation_server = listen_for_activation(endpoint, activate)
|
||||
if arguments.smoke_test:
|
||||
QTimer.singleShot(0, lambda: (window.close(), qt_application.quit()))
|
||||
exit_code = qt_application.exec()
|
||||
@@ -187,6 +216,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
logging_context.report_exception("startup", error)
|
||||
return 1
|
||||
finally:
|
||||
if activation_server is not None:
|
||||
activation_server.close()
|
||||
if store is not None:
|
||||
# The window invalidates queued UI results on close. Finish the
|
||||
# remaining read before releasing the shared SQLite connection.
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""Hold a data-root lock while the GUI owns its database and layout."""
|
||||
|
||||
from contextlib import contextmanager
|
||||
import errno
|
||||
import os
|
||||
import time
|
||||
|
||||
from PySide6.QtNetwork import QLocalServer, QLocalSocket
|
||||
|
||||
from .path_access import internal_path
|
||||
from .task_queue import _os_lock
|
||||
|
||||
|
||||
class InstanceUnavailable(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
@contextmanager
|
||||
def gui_instance(data_root):
|
||||
root = internal_path(data_root)
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
# OS locks release on process death. Keep the file so every contender locks the same inode.
|
||||
with (root / '.gui-instance.lock').open('a+b') as handle:
|
||||
identity = os.fstat(handle.fileno())
|
||||
endpoint = f'DxPartReplace-{identity.st_dev:x}-{identity.st_ino:x}'
|
||||
deadline = time.monotonic() + 30
|
||||
while True:
|
||||
try:
|
||||
_os_lock(handle, True)
|
||||
break
|
||||
except OSError as error:
|
||||
if error.errno not in (errno.EACCES, errno.EAGAIN, errno.EDEADLK):
|
||||
raise
|
||||
if _activate(endpoint):
|
||||
yield None
|
||||
return
|
||||
if time.monotonic() >= deadline:
|
||||
raise InstanceUnavailable('此数据目录已在使用,现有窗口暂未响应。')
|
||||
time.sleep(.05)
|
||||
yield endpoint
|
||||
|
||||
|
||||
def _activate(endpoint):
|
||||
socket = QLocalSocket()
|
||||
socket.connectToServer(endpoint)
|
||||
if not socket.waitForConnected(100):
|
||||
return False
|
||||
if os.name == 'nt':
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
|
||||
pid = wintypes.DWORD()
|
||||
get_pipe_pid = ctypes.windll.kernel32.GetNamedPipeServerProcessId
|
||||
get_pipe_pid.argtypes = (wintypes.HANDLE, ctypes.POINTER(wintypes.DWORD))
|
||||
if get_pipe_pid(int(socket.socketDescriptor()), ctypes.byref(pid)):
|
||||
ctypes.windll.user32.AllowSetForegroundWindow(pid.value)
|
||||
socket.write(b'activate\n')
|
||||
socket.flush()
|
||||
return (socket.bytesAvailable() > 0 or socket.waitForReadyRead(1000)) and socket.readAll() == b'1'
|
||||
|
||||
|
||||
def listen_for_activation(endpoint, activate):
|
||||
server = QLocalServer()
|
||||
server.setSocketOptions(QLocalServer.SocketOption.UserAccessOption)
|
||||
if os.name != 'nt':
|
||||
QLocalServer.removeServer(endpoint) # The lock owner can remove a crashed owner's socket.
|
||||
if not server.listen(endpoint):
|
||||
raise RuntimeError(server.errorString())
|
||||
|
||||
def accept():
|
||||
while server.hasPendingConnections():
|
||||
socket = server.nextPendingConnection()
|
||||
|
||||
def respond(socket=socket):
|
||||
if socket.canReadLine() and socket.readLine() == b'activate\n':
|
||||
activate()
|
||||
socket.write(b'1')
|
||||
socket.flush()
|
||||
socket.disconnectFromServer()
|
||||
|
||||
socket.disconnected.connect(socket.deleteLater)
|
||||
socket.readyRead.connect(respond)
|
||||
respond()
|
||||
|
||||
server.newConnection.connect(accept)
|
||||
return server
|
||||
@@ -0,0 +1,84 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
|
||||
|
||||
_SOURCE = Path(__file__).resolve().parents[2] / 'src'
|
||||
_APP = 'dx_productivity.trial_task_center.application'
|
||||
|
||||
|
||||
def _wait_for(predicate, description):
|
||||
deadline = time.monotonic() + 90
|
||||
while time.monotonic() < deadline:
|
||||
if predicate():
|
||||
return
|
||||
time.sleep(.05)
|
||||
raise AssertionError(description)
|
||||
|
||||
|
||||
def test_concurrent_gui_launches_activate_one_owner_and_recover_after_kill(tmp_path):
|
||||
root = tmp_path / 'Shared Root'
|
||||
independent = tmp_path / 'Independent Root'
|
||||
root.mkdir()
|
||||
store = TaskStore(root / 'task-center.db')
|
||||
try:
|
||||
task = store.create_task('Existing task')
|
||||
finally:
|
||||
store.close()
|
||||
processes = []
|
||||
env = os.environ | {'PYTHONPATH': str(_SOURCE), 'QT_QPA_PLATFORM': 'offscreen'}
|
||||
|
||||
def launch(path, *arguments):
|
||||
process = subprocess.Popen(
|
||||
[sys.executable, '-m', _APP, '--data-root', str(path), *arguments],
|
||||
env=env,
|
||||
)
|
||||
processes.append(process)
|
||||
return process
|
||||
|
||||
def log(path):
|
||||
logfile = path / 'logs/application.log'
|
||||
return logfile.read_text(encoding='utf-8') if logfile.exists() else ''
|
||||
|
||||
try:
|
||||
alias = root.with_name(root.name.upper()) if os.name == 'nt' else root
|
||||
contenders = [launch(root), launch(alias), launch(root), launch(alias)]
|
||||
_wait_for(lambda: sum(p.poll() is not None for p in contenders) >= 3,
|
||||
'Three concurrent launches should exit after handing off to one GUI')
|
||||
owners = [p for p in contenders if p.poll() is None]
|
||||
assert len(owners) == 1
|
||||
assert [p.returncode for p in contenders if p not in owners] == [0, 0, 0]
|
||||
_wait_for(lambda: log(root).count('instance_conflict') == 3,
|
||||
'The GUI should handle and log all three activation requests')
|
||||
assert log(root).count('application_start ') == 1
|
||||
|
||||
other = launch(independent)
|
||||
_wait_for(lambda: 'application_start ' in log(independent), 'Different root should start independently')
|
||||
assert other.poll() is None and owners[0].poll() is None
|
||||
|
||||
helper = launch(root, '--native-helper')
|
||||
assert helper.wait(timeout=60) == 2 # The helper validates its own required snapshot.
|
||||
assert log(root).count('instance_conflict') == 3
|
||||
|
||||
owners[0].kill()
|
||||
owners[0].wait(timeout=10)
|
||||
assert launch(root, '--smoke-test').wait(timeout=60) == 0
|
||||
assert log(root).count('application_start ') == 2
|
||||
assert log(root).count('application_clean_shutdown') == 1
|
||||
assert other.poll() is None
|
||||
store = TaskStore(root / 'task-center.db')
|
||||
try:
|
||||
assert [record.task_id for record in store.list_tasks()] == [task.task_id]
|
||||
finally:
|
||||
store.close()
|
||||
finally:
|
||||
for process in processes:
|
||||
if process.poll() is None:
|
||||
process.kill()
|
||||
process.wait(timeout=10)
|
||||
@@ -1,45 +0,0 @@
|
||||
"""Verify the original issue 33 evidence and summarize queues without running enclosed scripts."""
|
||||
import argparse
|
||||
from collections import Counter
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
def summarize(path):
|
||||
with path.open('rb') as stream:
|
||||
sha = hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
if sha != '1ac99eac3cf79bbf1f011d1d5fe833e92b98fba2c01546b3cfaf55a90b82d5b3':
|
||||
raise ValueError('Expected the original 1.3.2 field bundle from issue 33')
|
||||
queues = {}
|
||||
batches = {}
|
||||
with ZipFile(path) as archive:
|
||||
manifest = next(n for n in archive.namelist() if n.endswith('/SHA256SUMS.txt'))
|
||||
prefix = manifest.rsplit('/', 1)[0] + '/'
|
||||
entries = archive.read(manifest).decode('utf-8-sig').splitlines()
|
||||
for line in entries:
|
||||
digest, member = line.split(None, 1)
|
||||
with archive.open(prefix + member.strip().replace('\\', '/')) as stream:
|
||||
if hashlib.file_digest(stream, 'sha256').hexdigest() != digest.lower():
|
||||
raise ValueError('File checksum mismatch: ' + member)
|
||||
for member in archive.namelist():
|
||||
if '/data_full132/task-queues/' in member and member.endswith('.json'):
|
||||
queue = json.loads(archive.read(member))
|
||||
queues[Path(member).stem] = dict(
|
||||
total=len(queue['task_ids']), phase=queue['phase'],
|
||||
states=dict(Counter(row['state'] for row in queue['entries'].values())),
|
||||
isolated=list(queue.get('isolated_tasks', {})))
|
||||
if '/data_full132/batch-resources/' in member and member.endswith('/business-result.json'):
|
||||
result = json.loads(archive.read(member))
|
||||
fields = (result['payload'].get('result') or {}).get('fields', {})
|
||||
if 'queue_id' in fields:
|
||||
batches[result['batch_id']] = {key: fields.get(key) for key in
|
||||
('queue_id', 'paused', 'current_task_id')}
|
||||
return dict(sha256=sha, verified_files=len(entries), queues=queues, batch_results=batches)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('bundle', type=Path)
|
||||
print(json.dumps(summarize(parser.parse_args().bundle), ensure_ascii=False, indent=2))
|
||||
Reference in new issue
Block a user