fix: diagnose iCDB lost sessions and stop unsafe verification
This commit is contained in:
1 parent
a11eb3c766
commit
8a517d6f38
9 files changed
+685
-14
No files matched your search
@@ -127,6 +127,9 @@ def classify_output(exit_code: int | None, output: str, *, timed_out: bool = Fal
|
||||
"""Never invent success: PASS needs the success text and no error marker."""
|
||||
if timed_out:
|
||||
return 'TIMEOUT'
|
||||
from .icdb_recovery import parse_session_loss
|
||||
if parse_session_loss(output):
|
||||
return 'FAIL'
|
||||
if exit_code == 0 and SUCCESS_TEXT.search(output) and not ERROR_TEXT.search(output):
|
||||
return 'PASS'
|
||||
if ERROR_TEXT.search(output):
|
||||
@@ -277,6 +280,9 @@ def read_library_flag_with_retry(reader, library, block_name, *, attempts=3,
|
||||
def classify_failure_category(detail):
|
||||
text = str(detail or '')
|
||||
lower = text.casefold()
|
||||
from .icdb_recovery import ERROR_CODE, parse_session_loss
|
||||
if ERROR_CODE.casefold() in lower or parse_session_loss(text):
|
||||
return ERROR_CODE
|
||||
if any(code in lower for code in (
|
||||
'pcb_release_unconfirmed', 'icdb_release_unconfirmed',
|
||||
'icdb_session_unconfirmed', 'pcb_session_active', 'database_recovery_required')):
|
||||
@@ -554,6 +560,31 @@ def _run_verify_serialized(request, *, progress=None, flag_reader=None, process_
|
||||
pass
|
||||
finally:
|
||||
timing.end('failure_diagnostics')
|
||||
if result.status not in {'PASS', 'SKIPPED', 'QUEUE_STOP'}:
|
||||
from .icdb_recovery import ERROR_CODE, RECOVERY_ACTION, parse_session_loss, recovery_detail
|
||||
recovery = parse_session_loss(result.stderr)
|
||||
if recovery is None and result.evidence_path:
|
||||
try:
|
||||
saved = json.loads(result.evidence_path.with_name('diagnostics').joinpath(
|
||||
'icdb-recovery.json').read_text('utf-8'))
|
||||
recovery = parse_session_loss(saved.get('native_message', ''))
|
||||
except (OSError, ValueError, AttributeError):
|
||||
pass
|
||||
if recovery or ERROR_CODE.casefold() in result.stderr.casefold():
|
||||
detail = result.stderr
|
||||
if recovery and RECOVERY_ACTION not in detail:
|
||||
detail = (detail + '\n' + recovery_detail(recovery)).strip()
|
||||
result = replace(result, safe_to_continue=False, stderr=detail,
|
||||
error_category=ERROR_CODE)
|
||||
if recovery and result.evidence_path:
|
||||
try:
|
||||
record_path = result.evidence_path.parent/'diagnostics/icdb-recovery.json'
|
||||
record_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not record_path.is_file():
|
||||
record_path.write_text(json.dumps(recovery, ensure_ascii=False, indent=2),
|
||||
encoding='utf-8')
|
||||
except OSError:
|
||||
pass
|
||||
durations, unfinished = timing.snapshot()
|
||||
result = replace(result, timings_seconds=durations, incomplete_timing_phases=unfinished,
|
||||
error_category=(result.error_category or classify_failure_category(result.stderr)
|
||||
|
||||
Reference in new issue
Block a user