Skip to content

Remove all panics from TCP RR code - #1928

Merged
usamasaqib merged 11 commits into
usama.saqib/rr-refactorfrom
usama.saqib/remove-panics
Sep 10, 2026
Merged

Remove all panics from TCP RR code#1928
usamasaqib merged 11 commits into
usama.saqib/rr-refactorfrom
usama.saqib/remove-panics

Conversation

@usamasaqib

Copy link
Copy Markdown
Contributor

What does this PR do?

Remove all panics and replace them with proper error handling.

Motivation

Related issues

Additional Notes

@usamasaqib
usamasaqib changed the base branch from main to usama.saqib/rr-refactor August 28, 2026 11:56
@datadog-datadog-prod-us1

This comment has been minimized.

@usamasaqib
usamasaqib marked this pull request as ready for review September 9, 2026 12:03
@usamasaqib
usamasaqib requested a review from a team as a code owner September 9, 2026 12:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26351d03cf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lading/src/neper/rr.rs
Comment on lines +531 to 532
wait_for_shutdown_or_failure(shutdown, &mut fail_rx).await;
shutdown_flag.store(true, Relaxed);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Propagate server failures to the experiment controller

When a server worker returns an I/O error after startup, this new failure wait shuts down every TCP RR server thread and run_server returns the error, but inner_main only logs blackhole errors at lading/src/bin/lading.rs:568-572 and does not monitor them in a join set. The generator and experiment therefore continue for the configured duration after the entire blackhole has disappeared, producing incomplete or misleading load measurements; the blackhole task must propagate the failure to the experiment controller or trigger global shutdown.

AGENTS.md reference: AGENTS.md:L74-L78

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. I was hoping we were handling that properly already but it looks like the comment is right. We only log a warning for failures in black holes and target metrics. That's rather unfortunate.

It does look like main does the right thing for observers, generators & target errors.

This feels both slightly in scope and out of scope of your PR.

If you feel comfortable enough to change lading's main to fix this, that would be great. If you want to punt that over to me/team, that's understandable.

Let me know, we'll likely want to get that fix in before this PR gets merged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I don't have any other comments for this PR, everything else looks good to me)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey I can take a look at it. Maybe it is better to address that as a separate PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ed7cb5877

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lading/src/neper/rr.rs Outdated
Comment on lines +723 to +726
let socket = socket2::Socket::new(domain, socket2::Type::STREAM, Some(socket2::Protocol::TCP))?;
socket.set_nonblocking(true)?;
socket.set_cloexec(true)?;
socket.set_reuse_address(true)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add operation context to propagated socket errors

When any of these socket setup operations fails, each ? converts the error through transparent Error::Io, so users receive only a bare OS message and cannot determine whether socket creation, nonblocking mode, close-on-exec, or SO_REUSEADDR failed. Add contextual thiserror variants (including the address and failed operation) rather than replacing the previous diagnostic with an ambiguous error.

AGENTS.md reference: AGENTS.md:L74-L78

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e4d89396f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lading/src/neper/rr.rs
Comment on lines +566 to 569
if let Err(e) = wait_for_generator(
&control_listener,
control_addr,
params.flows,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Monitor worker failures while awaiting the generator

When a ready server worker fails before the control handshake completes—for example, an early data-port connection encounters a registration or reregistration error—the worker sends fail_tx, but this path awaits only wait_for_generator; fail_rx is not polled until after the flow count has been sent. The control port can therefore continue advertising a blackhole whose data thread has already exited, potentially causing the generator to open fewer or no usable flows; select on the failure receiver during this startup wait and shut down immediately.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not an issue. Data thread failing will abort the run anyway.

@usamasaqib
usamasaqib merged commit d764ea5 into usama.saqib/rr-refactor Sep 10, 2026
30 of 31 checks passed
@usamasaqib
usamasaqib deleted the usama.saqib/remove-panics branch September 10, 2026 13:10
usamasaqib added a commit that referenced this pull request Sep 11, 2026
* refactor rr

* do not swallow poll registry errors

* coordinate number of flows between generator and blackhole

* remove non ascii chars from comments

* fmt

* ensure shutdown flag is set on error paths

* decompose run_server

* update h2 due to security advisory

* ecapsulate control handshake

* Remove all panics from TCP RR code (#1928)

* bubble up errors

* move ready signal right before the event loop

* fail fast instead of waiting for shutdown signal after experiment duration

* error when shutdown happens before blackhole or generator ready

* encapsulate control handshake

* enrich socket errors with more context

* enrich poll errors with more context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants