Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
834528a
Add a ZMQ PayloadTransfer adapter for SimpleStorage
shun001 Nov 17, 2026
adc6e06
Add ZMQ PayloadTransfer UT
shun001 Nov 19, 2026
dd134df
Fix pre-commit
shun001 Nov 20, 2026
71799c7
Fix reliability issues
shun001 Nov 21, 2026
e2db801
[fix]Decouple SimpleStorage payload discovery and observability from ZMQ
shun001 Nov 21, 2026
9fb040b
Fix issues
shun001 Nov 24, 2026
15d7f76
[fix] Improve SimpleStorage shutdown and error reporting
0oshowero0 Nov 25, 2026
ba532bc
[refactor] Refine PayloadTransfer contract, locking, and test suite
0oshowero0 Nov 25, 2026
7a9e264
[refactor] Encapsulate PayloadClient, refine PayloadReply, and bound …
0oshowero0 Nov 25, 2026
f03f1fc
[fix] Preserve StorageKeyNotFoundError pickle path and clean up ZMQ d…
0oshowero0 Nov 25, 2026
eed315b
[refactor] Drop PayloadClient and wrap peer discovery in PayloadPeerInfo
0oshowero0 Nov 25, 2026
6f382ad
[fix] Classify payload fault transience and DeliveryState for safe re…
0oshowero0 Nov 25, 2026
416dbc1
[fix] Exclude expected missing-key races from storage error metrics
0oshowero0 Nov 25, 2026
0a0b719
[fix] Gate queued ZMQ requests on shutdown and whitelist transient ZM…
0oshowero0 Nov 25, 2026
bd2f989
[refactor] Simplify payload retry flow, peer bootstrap, and error module
0oshowero0 Nov 25, 2026
2c375c3
[refactor] Preserve healthy sockets on shutdown, unify retry loop, an…
0oshowero0 Nov 26, 2026
a33667b
[fix] Resolve mypy type narrowing and variable shadowing in _request_…
0oshowero0 Nov 26, 2026
11a85a5
[refactor] Delegate payload Prometheus accounting back to TQMetricsEx…
0oshowero0 Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_accept_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_sampling_an_unused_port_returns_none():


def test_unit_shutdown_stops_the_probe():
"""Nothing else calls stop(), so the sampling thread would outlive the unit."""
"""The sampling thread should stop with its storage unit."""
from unittest.mock import MagicMock

from transfer_queue.storage.simple_storage import SimpleStorageUnit
Expand All @@ -203,7 +203,7 @@ def test_unit_shutdown_stops_the_probe():
accept_probe=probe,
)

probe.stop.assert_called_once()
probe.stop.assert_called_once_with()


def test_shutdown_without_a_probe_is_a_no_op():
Expand Down
14 changes: 12 additions & 2 deletions tests/test_simple_storage_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
from omegaconf import OmegaConf

from transfer_queue.storage.bootstrap import simple_storage_bootstrap
from transfer_queue.storage.payload_transfer import PayloadPeerInfo
from transfer_queue.utils import common
from transfer_queue.utils.enum_utils import Role
from transfer_queue.utils.zmq_utils import ZMQServerInfo

_NODE_A = "01" * 28
_NODE_B = "02" * 28
Expand Down Expand Up @@ -96,7 +99,10 @@ def test_simple_storage_initialization_forwards_required_node_resource(monkeypat

monkeypatch.setattr(simple_storage_bootstrap, "get_node_round_robin_scheduling_strategies", get_strategies)
monkeypatch.setattr(simple_storage_bootstrap, "SimpleStorageUnit", storage_unit)
monkeypatch.setattr(simple_storage_bootstrap, "process_zmq_server_info", lambda _: {})
zmq_info = ZMQServerInfo(Role.STORAGE, "unit-id", "127.0.0.1", {"put_get_socket": 5555})
peer_info = PayloadPeerInfo("test", "opaque")
ray_get = MagicMock(return_value=[(zmq_info, peer_info)])
monkeypatch.setattr(simple_storage_bootstrap.ray, "get", ray_get)

conf = OmegaConf.create(
{
Expand All @@ -108,10 +114,14 @@ def test_simple_storage_initialization_forwards_required_node_resource(monkeypat
"required_node_resource": "storage_pool",
},
}
}
},
flags={"allow_objects": True},
)

handles = simple_storage_bootstrap.initialize_simple_storage(conf)

get_strategies.assert_called_once_with(1, required_node_resource="storage_pool")
ray_get.assert_called_once()
assert handles == {"TransferQueueStorageUnit#0": storage_handle}
assert conf.backend.SimpleStorage.zmq_info == {"TransferQueueStorageUnit#0": zmq_info}
assert conf.backend.SimpleStorage.payload_peers["unit-id"] == peer_info
35 changes: 30 additions & 5 deletions tests/test_storage_key_race.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
"""A key removed by a concurrent ``clear`` must stay distinguishable from a real storage fault."""

import logging
import pickle
from threading import Lock

import pytest
import torch

from transfer_queue.storage.payload_transfer import ZmqPayloadTransfer
from transfer_queue.storage.simple_storage import (
KEY_NOT_FOUND_MARKER,
SimpleStorageUnit,
StorageKeyNotFoundError,
StorageUnitData,
)
from transfer_queue.utils.perf_utils import IntervalPerfMonitor
from transfer_queue.utils.zmq_utils import ZMQMessage, ZMQRequestType


Expand All @@ -51,6 +55,19 @@ def test_key_not_found_is_a_key_error(storage_data):
storage_data.get_data(["log_probs"], [0])


def test_key_not_found_preserves_legacy_pickle_module_path():
# Rolling-upgrade Ray peers unpickle by (module, qualname); keep the pre-refactor module path.
err = StorageKeyNotFoundError("key 1 not found")
encoded = pickle.dumps(err)

assert StorageKeyNotFoundError.__module__ == "transfer_queue.storage.simple_storage"
assert b"transfer_queue.storage.simple_storage" in encoded
assert b"transfer_queue.storage.exceptions" not in encoded
restored = pickle.loads(encoded)
assert isinstance(restored, StorageKeyNotFoundError)
assert isinstance(restored, KeyError)


def test_unknown_field_still_raises_value_error(storage_data):
# A field absent from the schema is a caller bug, not the clear race.
with pytest.raises(ValueError, match="field 'missing' not found"):
Expand All @@ -66,18 +83,26 @@ def test_surviving_key_is_unaffected(storage_data):
def test_get_error_reply_is_marked_and_logged_at_debug(storage_data, caplog):
# The reply crosses ZMQ as text, so the marker is what lets the caller rebuild the type.
storage_data.clear([1])
unit_class = SimpleStorageUnit.__ray_metadata__.modified_class
unit = unit_class.__new__(unit_class)
unit.storage_unit_id = "storage_unit_0"
unit.storage_data = storage_data
request = ZMQMessage.create(
request_type=ZMQRequestType.GET_DATA,
sender_id="client_0",
body={"fields": ["log_probs"], "global_indexes": [1]},
)

unit_cls = SimpleStorageUnit.__ray_metadata__.modified_class
unit = unit_cls.__new__(unit_cls)
unit.storage_unit_id = "storage_unit_0"
unit.storage_data = storage_data
unit._storage_lock = Lock()
unit._requests_arrived = 0
unit._arrivals_by_op = {}
unit._metrics = None
unit._perf_monitor = IntervalPerfMonitor("storage_unit_0")

transport = ZmqPayloadTransfer(owner_id="storage_unit_0")
transport.listen(handle=unit._handle_payload)
with caplog.at_level(logging.DEBUG, logger="transfer_queue.storage.simple_storage"):
reply = unit_class._handle_get(unit, request)
reply = transport.handle_request(request)

assert reply.request_type == ZMQRequestType.GET_ERROR
assert KEY_NOT_FOUND_MARKER in reply.body["message"]
Expand Down
Loading
Loading