fix: recognize native startup journal order during recovery

This commit is contained in:
阿白叔 committed 2026-11-25 09:48:26 +08:00
1 parent 5bab125122
commit 806c1696ab
2 files changed
+6 -3

No files matched your search

+2 -2
View File
@@ -956,11 +956,11 @@ def _orphan_prewrite_client(path, job, session, state, identities):
'identity_verified', 'startup_close_requested', 'diagnostic_wm_close') 'identity_verified', 'startup_close_requested', 'diagnostic_wm_close')
for event in events): for event in events):
return None return None
stages = ('startup_supervisor_no_write', 'startup_prewrite_ready', 'pcb_baseline', 'pcb_worker_started') stages = ('startup_supervisor_no_write', 'pcb_baseline', 'startup_prewrite_ready', 'pcb_worker_started')
startup = [event for event in events if event.get('stage') in stages] startup = [event for event in events if event.get('stage') in stages]
if tuple(event['stage'] for event in startup) != stages: if tuple(event['stage'] for event in startup) != stages:
return None return None
waiting, ready, baseline, started = startup waiting, baseline, ready, started = startup
if any(event.get(key) != job[key] for event in (waiting, ready) if any(event.get(key) != job[key] for event in (waiting, ready)
for key in ('operation_id', 'project', 'pcb', 'desktop')): for key in ('operation_id', 'project', 'pcb', 'desktop')):
return None return None
+4 -1
View File
@@ -186,10 +186,13 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
import json import json
from contextlib import nullcontext from contextlib import nullcontext
from types import SimpleNamespace from types import SimpleNamespace
import win32event
from test_owned_idle_cleanup import owned_fixture from test_owned_idle_cleanup import owned_fixture
from cbb_refresh_verify import failed_session, residual_sessions from cbb_refresh_verify import failed_session, residual_sessions
root, job, _, windows, state = owned_fixture(tmp_path, monkeypatch) root, job, _, windows, state = owned_fixture(tmp_path, monkeypatch)
create_mutex = win32event.CreateMutex
monkeypatch.setattr(win32event, 'CreateMutex', lambda *args: create_mutex(None, False, None))
path = root/'session.json' path = root/'session.json'
session = session_record.read_session_record(path, evidence_root=root) session = session_record.read_session_record(path, evidence_root=root)
supervisor = dict(pid=10, image='C:/App/CbbRefreshVerify.exe', created_handle='supervisor-created', supervisor = dict(pid=10, image='C:/App/CbbRefreshVerify.exe', created_handle='supervisor-created',
@@ -214,9 +217,9 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
if obstacle == 'wrong_pcb': if obstacle == 'wrong_pcb':
command = command.replace(job['pcb'], job['pcb'] + '.wrong') command = command.replace(job['pcb'], job['pcb'] + '.wrong')
rows = [dict(stage='startup_supervisor_no_write', **binding), rows = [dict(stage='startup_supervisor_no_write', **binding),
dict(stage='pcb_baseline', pids=[]),
dict(stage='startup_prewrite_ready', worker_identity=session['processes'][0], dict(stage='startup_prewrite_ready', worker_identity=session['processes'][0],
baseline=dict(started_ns=42, files={}), **binding), baseline=dict(started_ns=42, files={}), **binding),
dict(stage='pcb_baseline', pids=[]),
dict(stage='pcb_worker_started', pcb_pid=12, command=command)] dict(stage='pcb_worker_started', pcb_pid=12, command=command)]
if obstacle == 'possible_write': if obstacle == 'possible_write':
rows.append(dict(stage='startup_supervisor_write_possible', **binding)) rows.append(dict(stage='startup_supervisor_write_possible', **binding))