GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(relay): keep recover() going past a transient entry failure · CortexLM/hypertrain@43cfcf7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/hypertrain/relay
    • core.py
  • tests/relay
    • test_lifecycle_v2.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/hypertrain/relay/core.py‎

Copy file name to clipboardExpand all lines: src/hypertrain/relay/core.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import annotations
99

1010
import hashlib
11+
import logging
1112
import secrets
1213
from collections.abc import AsyncIterator, Awaitable, Callable
1314
from contextlib import asynccontextmanager
@@ -508,6 +509,12 @@ def pending(
508509
except httpx.HTTPError:
509510
# Exact failure recorded by complete; custody remains retrievable.
510511
continue
512+
except (OSError, ValueError) as error:
513+
# Retriable (TimeoutError, ValidationError, SignatureError, I/O): record
514+
# nothing terminal so a later recover() tries again; never log payloads.
515+
logging.getLogger(__name__).warning(
516+
"relay recover deferred: %s", type(error).__name__
517+
)
511518

512519
def _scope(self, record: UploadRecord, hashes: list[str]) -> list[Pin]:
513520
if (
Collapse file

‎tests/relay/test_lifecycle_v2.py‎

Copy file name to clipboardExpand all lines: tests/relay/test_lifecycle_v2.py
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,3 +799,28 @@ async def scenario() -> None:
799799
assert completed.count(rotten.digest()) == 0
800800

801801
anyio.run(scenario)
802+
803+
804+
def test_recover_retries_after_transient_error(
805+
tmp_path: Path, caplog: pytest.LogCaptureFixture
806+
) -> None:
807+
# Given: the first journal entry's backing read times out once.
808+
async def scenario() -> None:
809+
async with httpx.AsyncClient() as client:
810+
rig = Rig(tmp_path, client)
811+
slow, honest = await interrupted_pair(rig)
812+
original = rig.store.get
813+
failing_get(rig, hashlib.sha256(b"abc").hexdigest(), TimeoutError())
814+
relay = rig.new_relay()
815+
await relay.recover()
816+
state = await relay.state()
817+
assert state.uploads[honest.digest()].receipt is not None
818+
assert state.uploads[slow.digest()].forward_error is None
819+
assert "TimeoutError" in caplog.text
820+
# When: the backing recovers and recovery runs again.
821+
rig.store.get = original # type: ignore[method-assign]
822+
await relay.recover()
823+
# Then: the transient entry is retried and completes.
824+
assert (await relay.state()).uploads[slow.digest()].receipt is not None
825+
826+
anyio.run(scenario)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.