fix: renew release progress at completed proof boundaries
This commit is contained in:
1 parent
e0bb2438e8
commit
de81bbf293
3 files changed
+122
No files matched your search
@@ -498,6 +498,7 @@ def owned_snapshot(path):
|
||||
@contextmanager
|
||||
def _prove_library_released(library, block_name=None, *, block_names=(), allow_unknown_checkpoint=False, stop=None):
|
||||
"""Hold all native database read handles during explicit lease release."""
|
||||
from .operation_queue import note_metadata_progress
|
||||
from .owner_probe import query_owners
|
||||
from .native_management import _retained_workers
|
||||
from .native_export_guard import assert_retained_exports_idle, prove_export_copies_released
|
||||
@@ -546,6 +547,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
|
||||
owners.append(item)
|
||||
if owners:
|
||||
raise LibraryBusy(f'原生进程仍存在,不能解除协调阻止:{owners}')
|
||||
note_metadata_progress()
|
||||
return owners
|
||||
check_owners()
|
||||
from .file_probe import hold_release_files
|
||||
@@ -558,6 +560,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
|
||||
blocked = LibraryBusy(str(error))
|
||||
blocked.winerror = getattr(error, 'winerror', None)
|
||||
raise blocked from error
|
||||
note_metadata_progress()
|
||||
if files['addresses']:
|
||||
# Native inspection needs the database; reacquire proof handles
|
||||
# and compare the exact address/project binding before commit.
|
||||
@@ -578,6 +581,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
|
||||
'exclusive_files', 'addresses', 'signatures', 'inspection_targets')):
|
||||
raise LibraryBusy('原生检查期间资源范围或地址身份变化。')
|
||||
files = current
|
||||
note_metadata_progress()
|
||||
export_proof = (prove_export_copies_released(library, allow_unknown_checkpoint=True)
|
||||
if allow_unknown_checkpoint else prove_export_copies_released(library))
|
||||
export_copies = stack.enter_context(export_proof)
|
||||
@@ -600,6 +604,7 @@ def release_retained_library(library, evidence_dir, *, block_name=None, block_na
|
||||
not the correctness of a partially changed library or its recovery state.
|
||||
"""
|
||||
import win32con, win32file
|
||||
from .operation_queue import note_metadata_progress
|
||||
library = Path(library).resolve(strict=True)
|
||||
from .session_record import (retained_session_snapshot, acknowledge_library_release,
|
||||
reconciled_retained_sessions)
|
||||
@@ -689,6 +694,7 @@ def release_retained_library(library, evidence_dir, *, block_name=None, block_na
|
||||
'operation_ids': [item['operation_id'] for item in reconciled_sessions]}
|
||||
pending = {**record, 'status': 'RELEASE_PENDING', 'lease_state': 'PENDING'}
|
||||
(root/'release.json').write_text(json.dumps(pending, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||
note_metadata_progress()
|
||||
for index, checkpoint in enumerate(checkpoints):
|
||||
if checkpoint.exists():
|
||||
data = checkpoint.read_bytes()
|
||||
@@ -696,6 +702,7 @@ def release_retained_library(library, evidence_dir, *, block_name=None, block_na
|
||||
archived.write_bytes(data)
|
||||
if archived.read_bytes() != data:
|
||||
raise OSError('阻止记录归档校验失败,保持库锁。')
|
||||
note_metadata_progress()
|
||||
if stop is not None and stop.is_set():
|
||||
raise InterruptedError('已停止释放检查')
|
||||
checkpoint.unlink() # Checkpoint JSON only; never .lock.
|
||||
|
||||
@@ -624,6 +624,7 @@ def release_targets_complete(rows):
|
||||
|
||||
|
||||
def _release_residual_sessions(plan, evidence_dir, *, stop=None, force=False, cancel_native=False):
|
||||
from .operation_queue import note_metadata_progress
|
||||
library = Path(plan['library']).resolve()
|
||||
root = Path(evidence_dir).resolve()/('sessions-'+uuid4().hex[:12])
|
||||
if root.is_relative_to(library.parent) or library.parent.is_relative_to(root):
|
||||
@@ -663,6 +664,7 @@ def _release_residual_sessions(plan, evidence_dir, *, stop=None, force=False, ca
|
||||
result['consent_path'] = str(consent_path)
|
||||
try:
|
||||
fresh = {r['pid']: r for r in query_process_snapshot()}
|
||||
note_metadata_progress()
|
||||
blocks = plan.get('block_names', ())
|
||||
roots = (tuple(library.parent/'ReusableBlocksLP'/b/'Work' for b in blocks)
|
||||
+ (library.parent/'SymbolLibs',)) if blocks else (library.parent,)
|
||||
@@ -700,7 +702,9 @@ def _release_residual_sessions(plan, evidence_dir, *, stop=None, force=False, ca
|
||||
row.update(outcome)
|
||||
if not save():
|
||||
return result # Preserve completed facts; stop further actions on storage failure.
|
||||
note_metadata_progress()
|
||||
after = {r['pid']: r for r in query_process_snapshot()}
|
||||
note_metadata_progress()
|
||||
remaining_windows = _process_windows({r['pid'] for r in result['sessions']
|
||||
if r['release_status'] == 'WAITING' and r['pid'] in after})
|
||||
for row in result['sessions']:
|
||||
|
||||
Reference in new issue
Block a user