fix(ipc): gracefully handle SHM errors instead of unwrapping - #2408
fix(ipc): gracefully handle SHM errors instead of unwrapping#2408bwoebi wants to merge 1 commit into
Conversation
Clippy Allow Annotation ReportTracked Clippy
By file and crateBy file
By crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. Panic-inducing macros in particular should be avoided. In the future, this report may become a PR-blocking quality gate. |
📚 Documentation Check Results📦
|
|
🔒 Cargo Deny Results📦
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7bb94b4645
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| handle | ||
| .set_mapping_size(expected_size) | ||
| .map_err(io::Error::other)?; |
There was a problem hiding this comment.
Restore the macOS mapping size after publication fails
When the metadata-page mmap fails after set_mapping_size succeeds, this function returns the error but remaps self using the enlarged local size. A later write of the same size therefore skips ensure_space, reports success, and writes data even though the shared size word was never advanced by fetch_max, so readers continue using the old size and cannot observe the payload. Restore the previous local size on this error path so a subsequent write retries publishing the new size.
AGENTS.md reference: AGENTS.md:L70-L73
Useful? React with 👍 / 👎.
| limiter: if path.product() == RemoteConfigProduct::LiveDebugging { | ||
| Some(SHM_LIMITER.lock_or_panic().alloc()) | ||
| crate::tracer::with_shm_limiter(|mem| mem.alloc()).and_then(|result| { |
There was a problem hiding this comment.
Retry limiter allocation for an existing live-debug config
If allocation fails here during transient shared-memory pressure, the immutable StoredShmFile.limiter is permanently set to None. Contrary to the warning, subsequent remote-config fetches reuse this stored file, and ConfigFileStorage::update only replaces its handle, so even after SHM recovers the config keeps serializing limiter index 0 until it is removed and stored again. Retrying allocation for existing live-debug files would restore rate limiting after recovery.
AGENTS.md reference: AGENTS.md:L70-L73
Useful? React with 👍 / 👎.
| if let Err(e) = | ||
| writer.write(&serde_json::to_vec(&status.info).unwrap()) | ||
| { |
There was a problem hiding this comment.
Retry agent-info publication after a failed write
When growing this segment fails transiently, the fetcher has already saved status.state_hash at line 119, so subsequent /info polls normally return SameState and never execute this write again. The in-process future is updated while SHM readers remain on the previous agent info indefinitely, until the agent's state hash changes for an unrelated reason. Preserve the pending payload or avoid advancing state until the SHM publication succeeds.
AGENTS.md reference: AGENTS.md:L70-L73
Useful? React with 👍 / 👎.
BenchmarksComparisonBenchmark execution time: 2026-08-24 20:24:32 Comparing candidate commit 7bb94b4 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2 metrics, 0 unstable metrics.
|
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | 7bb94b4 | 1787602591 | bob/shm-error |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| two way interface | execution_time | 21.277µs | 21.744µs ± 0.369µs | 21.659µs ± 0.107µs | 21.829µs | 22.150µs | 22.637µs | 25.813µs | 19.18% | 7.176 | 73.240 | 1.69% | 0.026µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| two way interface | execution_time | [21.693µs; 21.795µs] or [-0.235%; +0.235%] | None | None | None |
Group 2
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | 7bb94b4 | 1787602591 | bob/shm-error |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| write only interface | execution_time | 2.054µs | 2.069µs ± 0.010µs | 2.067µs ± 0.005µs | 2.073µs | 2.093µs | 2.099µs | 2.100µs | 1.63% | 1.381 | 1.483 | 0.49% | 0.001µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| write only interface | execution_time | [2.068µs; 2.071µs] or [-0.068%; +0.068%] | None | None | None |
Baseline
Baseline benchmark details
Group 1
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | eeba827 | 1787601922 | main |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| two way interface | execution_time | 21.099µs | 22.083µs ± 0.256µs | 22.034µs ± 0.130µs | 22.207µs | 22.550µs | 22.837µs | 23.194µs | 5.26% | 0.707 | 2.497 | 1.16% | 0.018µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| two way interface | execution_time | [22.048µs; 22.119µs] or [-0.161%; +0.161%] | None | None | None |
Group 2
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | eeba827 | 1787601922 | main |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| write only interface | execution_time | 2.056µs | 2.068µs ± 0.006µs | 2.068µs ± 0.003µs | 2.070µs | 2.078µs | 2.091µs | 2.096µs | 1.33% | 1.738 | 6.033 | 0.27% | 0.000µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| write only interface | execution_time | [2.068µs; 2.069µs] or [-0.038%; +0.038%] | None | None | None |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
This prevents errors especially around ENOSPC on customers environments from stopping the sidecar alltogether.