fix: prove retained database release before batch admission

This commit is contained in:
阿白叔 committed 2026-11-25 14:33:32 +08:00
1 parent b3d69ee722
commit 33a41b25fb
2 files changed
+24 -1

No files matched your search

+4 -1
View File
@@ -1605,8 +1605,11 @@ def wait_for_batch_release(request, context, *, progress=None, timeout_seconds=1
context.check_active() context.check_active()
if library_available(library, live_only=True): if library_available(library, live_only=True):
try: try:
# A restarted observer owns no in-process LibraryLock.
# Its exited client still requires a proof for the recorded scope.
recheck_previous_release(library, Path(request.evidence_dir)/'previous-release', recheck_previous_release(library, Path(request.evidence_dir)/'previous-release',
block_name=request.block_name, stop=context.stop, infer_scope=True) block_name=request.block_name, stop=context.stop, infer_scope=True,
required=not library_available(library))
except LibraryBusy as error: except LibraryBusy as error:
detail = str(error) detail = str(error)
else: else:
+20
View File
@@ -29,6 +29,26 @@ def test_batch_admission_reports_resource_at_entry(tmp_path, monkeypatch):
verify_runner.wait_for_batch_release(request, BatchTaskContext(str(library)), timeout_seconds=0) verify_runner.wait_for_batch_release(request, BatchTaskContext(str(library)), timeout_seconds=0)
def test_batch_rechecks_recorded_session_after_client_exit(tmp_path, monkeypatch):
from cbb_refresh_verify import session_record, verify_runner
library = tmp_path / 'library.lmc'
library.touch()
request = VerifyRequest(library, 'Next', tmp_path / 'evidence')
monkeypatch.setattr(session_record, 'library_available', lambda _, live_only=False: live_only)
checks = []
def recheck(*args, **kwargs):
checks.append(kwargs.get('required', False))
if kwargs.get('required'):
raise LibraryBusy('记录中的客户端已退出,共享 iCDB 数据库仍在使用')
monkeypatch.setattr('cbb_refresh_verify.library_lock.recheck_previous_release', recheck)
with pytest.raises(QueueUnavailable, match='共享 iCDB 数据库仍在使用'):
verify_runner.wait_for_batch_release(request, BatchTaskContext(str(library)), timeout_seconds=0)
assert checks == [True]
def test_batch_waits_for_recorded_save_past_ordinary_release_deadline(tmp_path, monkeypatch): def test_batch_waits_for_recorded_save_past_ordinary_release_deadline(tmp_path, monkeypatch):
from cbb_refresh_verify import verify_runner from cbb_refresh_verify import verify_runner