fix: prove prewrite cancellation and bound recovery metadata lifetime
This commit is contained in:
1 parent
32dcd80d1e
commit
906cfc06be
14 files changed
+659
-60
No files matched your search
@@ -243,7 +243,8 @@ def _stop_worker(process, *, timeout=5, wait_for_native_write=True):
|
||||
process.wait(timeout=timeout)
|
||||
except Exception:
|
||||
pending = getattr(process, 'native_write_pending', lambda: False)()
|
||||
if wait_for_native_write and pending is not False and not getattr(process, '_stop_wait_complete', False):
|
||||
wait_required = wait_for_native_write() if callable(wait_for_native_write) else wait_for_native_write
|
||||
if wait_required and pending is not False and not getattr(process, '_stop_wait_complete', False):
|
||||
from .defaults import NATIVE_WRITE_STOP_WAIT_SECONDS
|
||||
try:
|
||||
process.wait(timeout=max(0, NATIVE_WRITE_STOP_WAIT_SECONDS - timeout))
|
||||
@@ -985,6 +986,15 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
except Exception as error:
|
||||
return finish(VerifyResult('FAIL', stderr=str(error)))
|
||||
events = root/'events.jsonl'
|
||||
prewrite_eligible = not (request.diagnostic_only or request.interactive_input or request.native_lm_verify or consent)
|
||||
def startup_phase(stage,**facts):
|
||||
record={k:job[k] for k in ('operation_id','project','pcb','desktop')}
|
||||
with events.open('a',encoding='utf-8') as stream:
|
||||
stream.write(json.dumps(dict(stage=stage,**record,**facts))+'\n')
|
||||
def before_dialog_action(snapshot,action):
|
||||
name=action.get('action') if isinstance(action,dict) else action
|
||||
if name not in ('dismiss_tip','accept_license','decline_database_log'):
|
||||
startup_phase('startup_supervisor_write_possible',action=name,pid=snapshot.pid,hwnd=snapshot.hwnd)
|
||||
offset = 0
|
||||
target_pid = None
|
||||
diagnostic_closing = False
|
||||
@@ -1011,6 +1021,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
native.__exit__(None, None, None)
|
||||
phase_entered = False
|
||||
try:
|
||||
if prewrite_eligible:startup_phase('startup_supervisor_no_write')
|
||||
timing.begin('worker_setup')
|
||||
with (root/'worker.log').open('w', encoding='utf-8') as log:
|
||||
check_active()
|
||||
@@ -1037,14 +1048,14 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
from .dialog_rules import default_rules_path, load_rules
|
||||
dialog_agent = DialogAgentClient.start(process, root/'dialog-agent', stop=stop)
|
||||
dialog_supervisor = DialogSupervisor(
|
||||
AgentDialogBackend(dialog_agent, pids=lambda: {
|
||||
AgentDialogBackend(dialog_agent, before_action=before_dialog_action if prewrite_eligible else None, pids=lambda: {
|
||||
int(pid) for pid in (target_pid, lm_pid, launcher_pid) if pid}),
|
||||
rules=load_rules(default_rules_path(), diagnostic_only=request.diagnostic_only),
|
||||
)
|
||||
else:
|
||||
dialog_supervisor = DialogSupervisor(Win32DialogBackend(
|
||||
lambda: ({value for value in (target_pid, lm_pid) if value is not None}),
|
||||
desktop=process.desktop,
|
||||
desktop=process.desktop,before_action=before_dialog_action if prewrite_eligible else None,
|
||||
))
|
||||
else:
|
||||
dialog_supervisor = dialog_supervisor_factory(
|
||||
@@ -1070,7 +1081,9 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
'已请求停止,等待当前原生操作返回')
|
||||
_notify_progress(progress, {'stage': 'save_stop_requested', 'block': request.block_name,
|
||||
'detail': detail})
|
||||
_stop_worker(process, wait_for_native_write=not request.diagnostic_only)
|
||||
from .failed_session import cancelled_prewrite_startup
|
||||
_stop_worker(process, wait_for_native_write=False if request.diagnostic_only else
|
||||
lambda:cancelled_prewrite_startup(job,target_pid) is None)
|
||||
return finish(VerifyResult('CANCELLED', stderr='已取消当前校验。',
|
||||
safe_to_continue=False, error_stage=phase.value))
|
||||
if events.exists():
|
||||
|
||||
Reference in new issue
Block a user