Skip to content

Commit ed422cd

Browse files
authored
Merge pull request #104 from DeepLink-org/fix_stream_mismatch
fix stream name mismatch inbox => stream
2 parents 1f1f017 + 66450ff commit ed422cd

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

dlslime-ctrl/src/redis_repo.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,14 @@ impl RedisRepo {
283283
}
284284
}
285285

286-
// 5. Delete inbox
286+
// 5. Delete mailbox streams/inbox
287+
let stream_key = self.scoped_key(scope, &["stream", agent_name]);
288+
redis::cmd("DEL")
289+
.arg(&stream_key)
290+
.query_async::<()>(&mut *conn)
291+
.await
292+
.ok();
293+
287294
let inbox_key = self.scoped_key(scope, &["inbox", agent_name]);
288295
redis::cmd("DEL")
289296
.arg(&inbox_key)

dlslime/dlslime/peer_agent/_agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def __init__(
200200

201201
# Build Redis key prefix from scope parameter
202202
self._redis_key_prefix = scope or ""
203+
self._session_started_at = time.time()
203204

204205
# NanoCtrl HTTP client
205206
self._client = NanoCtrlClient(ctrl_url, scope=self._redis_key_prefix or None)
@@ -670,6 +671,7 @@ def _cleanup_stale_exchange_keys(self) -> None:
670671
patterns = [
671672
f"{prefix}exchange:{self.alias}:*",
672673
f"{prefix}exchange:*:{self.alias}",
674+
f"{prefix}exchange:*:{self.alias}:*",
673675
]
674676
try:
675677
keys_to_delete: list[str] = []

dlslime/dlslime/peer_agent/_mailbox.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def start(self) -> None:
6363
# so losing the message stalls the handshake forever.
6464
#
6565
# Instead, _listen_loop reads from "0-0" and processes every message
66-
# on the stream. Truly stale messages from a prior crashed session
67-
# with the same alias fail endpoint.connect at handshake time — the
68-
# listen loop catches that and continues, so later in-flight qp_ready
69-
# from the current peer session still completes the handshake.
66+
# on the stream. Stale messages must be removed when the previous
67+
# agent incarnation is cleaned up. Do not use local wall-clock
68+
# timestamps here: a valid early qp_ready can predate this listener,
69+
# and sender/receiver clocks may drift across nodes.
7070
self._thread = threading.Thread(target=self._listen_loop, daemon=True)
7171
self._thread.start()
7272
logger.info(
@@ -316,7 +316,6 @@ def _try_connect_peer_inner(
316316
"peer": self._agent.alias,
317317
"qp_info": json.dumps(my_qp_info, default=str),
318318
"conn_meta": json.dumps(my_conn_meta, default=str),
319-
"timestamp": str(time.time()),
320319
},
321320
maxlen=1000,
322321
approximate=True,

0 commit comments

Comments
 (0)