net: a replaced copy let go with its track open loses a group it gave up under the resume point

Đang mở
#10,340 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
distributed-systems

Hướng nghiên cứu

Start with rs/moq-net/src/model/resume.rs and reproduce the failure using the supplied test in mod test, checking why asked_for(&b, 2) is false. Then read Reader::owed and how it handles replaced copies and runs they can still deliver. Done means the fill for group 2 is retained and the supplied scenario passes without breaking the three named regression tests.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

quest

A logical reader can lose a group under the serving copy's resume point after a route switch, when a replaced copy gives that group up and is then let go while its track stays open.

Scenario

  1. Route A's copy holds groups 0, 1 and 4. The reader reads them, then the front switches to route B, whose live feed starts at 4 (so 2 and 3 can come from B only as fills).
  2. A drops group 2, while group 3 may still land on it. Reader::owed subtracts A's whole fed span (copy.replaced && !copy.fills && copy.feeds), so no fill is kept for 2 either.
  3. A then skips group 3 while its track stays open. Nothing is left to land on A, so Copy::retains returns No and let_go drops it.
  4. ran_short re-arms the serving route's walk only when poll_first sees the copy end cleanly (done = Some(Ok)), which never happens here. gave_up covers only drains. Nothing asks B for group 2, and an ordered read waits at it.

This affects bounded and unbounded reads alike. On main it predates moq-dev/moq#10176, which only widened owed and ran_short to unbounded reads.

Reproduction

Add this to rs/moq-net/src/model/resume.rs's mod test. It fails at asked_for(&b, 2):

	/// A replaced copy let go while its track stays open, after giving up one group the reader
	/// lacks and having the rest it still fed skipped, leaves that group to the serving route:
	/// no fill was kept for what it still fed.
	#[test]
	fn a_replaced_copy_let_go_open_has_a_group_it_gave_up_asked_again() {
		let routes = Producer::new();
		let logical = logical(&routes);
		let a = received_copy();
		routes.serve(a.consume());
		let mut sub = subscribe_until(&logical, 6);
		for key in [0, 1, 4] {
			write(&a, key);
		}
		let mut got = drain(&mut sub, false);
		got.sort_unstable();
		assert_eq!(got, [0, 1, 4]);
		let mut b = received_copy();
		routes.serve(b.consume());
		// Its live feed starts at the resume point, so 2 comes only as a fill.
		b.start_at(4).unwrap();
		write(&b, 5);
		assert_eq!(drain(&mut sub, false), [5]);
		// The old route gives 2 up while 3 may still land on it.
		a.drop_groups(2..3);
		assert!(sub.poll_recv_group(&fresh()).is_pending());
		// Then it skips 3, its track still open, so nothing is left to land on it.
		a.skip_groups(3..4);
		assert!(sub.poll_recv_group(&fresh()).is_pending());
		assert!(sub.poll_recv_group(&fresh()).is_pending());
		assert!(asked_for(&b, 2), "{:?}", b.subscription());
		write(&b, 2);
		assert_eq!(drain(&mut sub, false), [2]);
	}

What a fix has to keep

The obvious fix re-arms Resumed::Route whenever let_go drops a copy that still fed a group the reader lacks under the resume point. That over-asks: it breaks a_kept_out_key_above_a_finished_backfill_is_asked_from_itself (a copy let go past the budget gets asked again), and even limited to copies within their budget it breaks an_unplaced_time_start_waits_on_a_replaced_copy and ..._only_to_its_end (the serving route gets asked for history those tests leave unasked). The reviewer's suggestion is narrower: in Reader::owed, subtract only the runs the replaced copy can still deliver (not its drops), so the fill for group 2 is kept.

Found by Codex review on moq-dev/moq#10176.

(Written by Claude Opus 5.5)

Ngôn ngữ chính
Rust
Star
1.6k
Fork
251
Merge trung bình
10 giờ 10 phút
Pull request đã merge (30 ngày)
822

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của moq-dev/moq

Tất cả issue của moq-dev/moq

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.