fix: keep prewrite-cancelled CBBs available for fresh admission

This commit is contained in:
阿白叔 committed 2026-11-23 19:34:25 +08:00
1 parent 48f38d1bdd
commit 3b4323405a
3 files changed
+46 -5

No files matched your search

+8 -4
View File
@@ -1951,7 +1951,11 @@ class MainWindow(QWidget):
write_maintenance_report(requests, results, report, ())
except Exception as error:
self._emit_job(job, 'event', {'stage': 'report_failed', 'detail': str(error)})
affected = [req.block_name for req, result in zip(requests, results) if result.status != 'SKIPPED']
# A proven pre-write cancel can be submitted again. The next
# admission still rereads the catalog, status and occupancy.
affected = [req.block_name for req, result in zip(requests, results)
if result.status != 'SKIPPED'
and not (result.status == 'CANCELLED' and result.cancelled_before_write)]
safe = all(result.safe_to_continue for result in results)
self._emit_job(job, 'batch_ready', (results, report))
refresh = None
@@ -2202,12 +2206,12 @@ class MainWindow(QWidget):
if len(outcome) <= 2:
return
results, _, affected, refresh = outcome
if refresh is None:
if refresh is not None:
self._apply_refreshed_records(refresh)
elif affected:
reason = ('状态尚未复核,请重新读取。' if all(r.safe_to_continue for r in results)
else '会话或数据库安全未确认;暂缓原生状态复核,请确认释放后重新读取。')
self._defer_status_refresh(affected, reason)
else:
self._apply_refreshed_records(refresh)
from shiboken6 import isValid
summary = getattr(self, 'summary', None)
self.status_label.setText(summary.text().replace('\n', ' ') if summary is not None and isValid(summary)
+4 -1
View File
@@ -108,6 +108,7 @@ class VerifyResult:
release_proof: dict | None = None
write_outcome: dict | None = None
session_record_path: Path | None = None
cancelled_before_write: bool = False
def resolve_importer(mentor_bin: str | None = None) -> Path:
@@ -1153,8 +1154,10 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
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)
prewrite = cancelled_prewrite_startup(job, target_pid) is not None
return finish(VerifyResult('CANCELLED', stderr='已取消当前校验。',
safe_to_continue=False, error_stage=phase.value))
safe_to_continue=False, error_stage=phase.value,
cancelled_before_write=prewrite))
if events.exists():
with events.open(encoding='utf-8') as stream:
stream.seek(offset)
+34
View File
@@ -337,3 +337,37 @@ def test_pcb_open_option_is_bound_only_to_ordinary_verify(qtbot, tmp_path, monke
qtbot.waitUntil(lambda: not window.busy)
assert len(requests) == 1
assert requests[0].auto_confirm_pcb_open is enabled
@pytest.mark.parametrize('prewrite', (True, False))
def test_prewrite_cancellation_can_resubmit_and_rechecks_ready(qtbot, tmp_path, monkeypatch, prewrite):
calls = []
reads = []
def verify(request):
calls.append(request.block_name)
window.stop.set()
return VerifyResult('CANCELLED', safe_to_continue=False, cancelled_before_write=prewrite)
def read(names, library):
reads.append(names)
return {'Beta': 'READY' if len(reads) > 1 else 'PENDING'}
window = load_window(qtbot, tmp_path, monkeypatch, verifier=verify,
status_refresher=lambda *_: pytest.fail('cancelled batch started a status refresh'))
window.catalog_reader = object()
monkeypatch.setattr(window, '_execution_status_reader', lambda *_: read)
window.search_edit.setText('beta')
window.batch_button.click()
qtbot.waitUntil(lambda: not window.busy)
assert calls == ['Beta']
assert window.visible_records()[0].status == ('PENDING' if prewrite else 'UNKNOWN')
assert window.batch_button.isEnabled() == prewrite
if not prewrite:
return
window.batch_button.click()
qtbot.waitUntil(lambda: not window.busy)
assert reads == [('Beta',), ('Beta',)]
assert calls == ['Beta']
assert window.cbb_table.item(1, 3).text().startswith('SKIPPED:')