fix: isolate ICDB checks and recover scoped native sessions
This commit is contained in:
1 parent
1acfbd6374
commit
1bd7589fef
82 files changed
+7770
-1583
No files matched your search
@@ -48,6 +48,7 @@ class BatchStatusRecord:
|
||||
detail: str = ""
|
||||
fingerprint: str = ""
|
||||
timestamp: str = ""
|
||||
block_type: str = "RULP"
|
||||
|
||||
@property
|
||||
def completed(self) -> bool:
|
||||
@@ -109,6 +110,8 @@ def fingerprint_library(lmc: Path) -> LmcFingerprint:
|
||||
# digest so a changed central library can never reuse an old status row.
|
||||
content_sha256 = _sha256_file(path)
|
||||
combined = hashlib.sha256()
|
||||
combined.update(str(path).casefold().encode('utf-8', errors='surrogatepass'))
|
||||
combined.update(b'\0')
|
||||
combined.update(content_sha256.encode("ascii"))
|
||||
combined.update(b"\0" + str(stat.st_size).encode("ascii"))
|
||||
combined.update(b"\0" + str(stat.st_mtime_ns).encode("ascii") + b"\0")
|
||||
@@ -165,6 +168,7 @@ class BatchCheckpoint:
|
||||
detail=str(payload.get("detail") or ""),
|
||||
fingerprint=str(payload.get("fingerprint") or ""),
|
||||
timestamp=str(payload.get("timestamp") or ""),
|
||||
block_type=str(payload.get("block_type") or "RULP"),
|
||||
)
|
||||
return cls(records)
|
||||
|
||||
@@ -212,7 +216,7 @@ class BatchStatusSession:
|
||||
for index, name in enumerate(names):
|
||||
previous = checkpoint.get(name)
|
||||
if (previous and previous.status in {'READY', 'PENDING'}
|
||||
and previous.fingerprint == fingerprint.sha256):
|
||||
and previous.fingerprint == fingerprint.sha256 and previous.block_type == block_type):
|
||||
results.append(previous)
|
||||
continue
|
||||
try:
|
||||
@@ -224,11 +228,12 @@ class BatchStatusSession:
|
||||
block_name=name, status=result.status, source=result.source,
|
||||
raw_status=result.raw_status, detail=result.detail,
|
||||
fingerprint=fingerprint.sha256, timestamp=_now(),
|
||||
block_type=block_type,
|
||||
)
|
||||
except BridgeUnavailable as error:
|
||||
record = BatchStatusRecord(block_name=name, status="UNAVAILABLE",
|
||||
detail=str(error), fingerprint=fingerprint.sha256,
|
||||
timestamp=_now())
|
||||
timestamp=_now(), block_type=block_type)
|
||||
except BridgeResponseError as error:
|
||||
message = str(error)
|
||||
lower_message = message.casefold()
|
||||
@@ -242,15 +247,15 @@ class BatchStatusSession:
|
||||
else "UNAVAILABLE" if unavailable
|
||||
else "MALFORMED" if malformed else "ERROR")
|
||||
record = BatchStatusRecord(block_name=name, status=status, detail=message,
|
||||
fingerprint=fingerprint.sha256, timestamp=_now())
|
||||
if server is not None and status not in {"UNAVAILABLE", "MALFORMED"}:
|
||||
fingerprint=fingerprint.sha256, timestamp=_now(), block_type=block_type)
|
||||
if server is not None and status != "UNAVAILABLE":
|
||||
try:
|
||||
server.restart()
|
||||
except BridgeUnavailable:
|
||||
pass
|
||||
except Exception as error: # bridge failures isolate one CBB
|
||||
record = BatchStatusRecord(block_name=name, status="ERROR", detail=str(error),
|
||||
fingerprint=fingerprint.sha256, timestamp=_now())
|
||||
fingerprint=fingerprint.sha256, timestamp=_now(), block_type=block_type)
|
||||
if server is not None:
|
||||
try:
|
||||
server.restart()
|
||||
@@ -258,7 +263,7 @@ class BatchStatusSession:
|
||||
pass
|
||||
checkpoint.append(checkpoint_path, record)
|
||||
results.append(record)
|
||||
if record.status in {"UNAVAILABLE", "MALFORMED"} and index + 1 < len(names):
|
||||
if record.status == "UNAVAILABLE" and index + 1 < len(names):
|
||||
# Startup/protocol failures cannot be repaired by retrying
|
||||
# the same request contract for every CBB.
|
||||
# Preserve a terminal record for each remaining name so a
|
||||
@@ -267,6 +272,7 @@ class BatchStatusSession:
|
||||
unavailable_record = BatchStatusRecord(
|
||||
block_name=remaining, status=record.status, detail=record.detail,
|
||||
fingerprint=fingerprint.sha256, timestamp=_now(),
|
||||
block_type=block_type,
|
||||
)
|
||||
checkpoint.append(checkpoint_path, unavailable_record)
|
||||
results.append(unavailable_record)
|
||||
|
||||
Reference in new issue
Block a user