Skip to content

fix: add serverless leak fix oneoff#4318

Merged
NathanFlurry merged 1 commit intomainfrom
02-26-fix_add_serverless_leak_fix_oneoff
Feb 27, 2026
Merged

fix: add serverless leak fix oneoff#4318
NathanFlurry merged 1 commit intomainfrom
02-26-fix_add_serverless_leak_fix_oneoff

Conversation

@MasterPtato
Copy link
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app
Copy link

railway-app bot commented Feb 26, 2026

🚅 Deployed to the rivet-pr-4318 environment in rivet-frontend

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web Feb 26, 2026 at 7:58 pm
frontend-cloud 😴 Sleeping (View Logs) Web Feb 26, 2026 at 7:53 pm
frontend-inspector 😴 Sleeping (View Logs) Web Feb 26, 2026 at 7:52 pm
ladle ❌ Build Failed (View Logs) Web Feb 26, 2026 at 7:46 pm
mcp-hub ✅ Success (View Logs) Web Feb 26, 2026 at 7:44 pm

Copy link
Contributor Author

MasterPtato commented Feb 26, 2026

@claude
Copy link

claude bot commented Feb 26, 2026

PR Review: fix: add serverless leak fix oneoff

Status: Merged. Feedback below is for the record and future reference.

Overall this is a focused, well-scoped fix. The core logic (read orphaned slots from the unsubspaced location, atomically re-apply to the correct pegboard subspace in a single transaction) is correct. Below are issues found during review.


Medium Severity

1. dry_run + flip interaction is misleading (cli.rs)

When a user runs --dry-run -f, the logged slots value does not reflect the flip that would be applied, making dry-run validation inaccurate:

if dry_run {
    tracing::info!(?slots, "found lost slots");  // shows raw slots, ignores flip
} else {
    let slots = if flip { slots * -1 } else { slots };
    // ...
}

Suggestion: compute the (potentially-flipped) value before the if dry_run branch so both paths log the same effective value.


2. 5-second transaction timeout may be too tight

The operation uses StreamingMode::WantAll across the entire unsubspaced ServerlessDesiredSlotsKey space, applies atomic ops, and wraps everything in a 5-second tokio::time::timeout. FDB transactions also have a hard 5-second default limit. For a production environment with many namespaces/runners, this scan could time out silently before completing. Consider paginating the scan or at minimum adding a comment documenting this limitation.


Low Severity

3. slots * -1 can overflow for i64::MIN

In release builds, negating i64::MIN silently wraps back to i64::MIN. Prefer idiomatic Rust negation:

// Before
let slots = if flip { slots * -1 } else { slots };

// After
let slots = if flip { -slots } else { slots };

4. No success/completion message after transaction

The Ok(Ok(_)) => {} arm is silent. An operator has no way to distinguish "completed with 0 entries" from a quiet failure or timeout. Even a simple tracing::info!("reapply complete") would help.


5. No confirmation prompt before destructive write

Other destructive subcommands (e.g., Clear) require a --yes flag or interactive prompt. ReapplyLostServerless modifies production data directly when --dry-run is not set, relying entirely on operator discipline. Consider adding a --yes confirmation guard consistent with the rest of the CLI.


6. Missing #[command(name = "...")] on Oneoff variant

All other variants use explicit #[command(name = "...")] attributes (e.g., #[command(name = "cd")]). Oneoff uses clap's default snake-case derivation. Not a bug, but inconsistent with the established convention.


Non-issues / Good Choices

  • Correct cross-subspace transaction: Reading without subspace (where data is lost) and writing with the pegboard subspace in a single serializable transaction is the right FDB pattern.
  • rivet-types dependency promotion: Moving from dev-dependencies to dependencies is correct since it is now used in production code.
  • Unused protocol_version_entry removal (runner2.rs): The key was being read inside check_expired but never consumed after the try_join! destructuring — removing it is both correct cleanup and a small performance win (one fewer snapshot read per expiry check).
  • Unused import removals: All removals (Deserialize, MAX_BODY_SIZE) are accurate.
  • default_value_t = false cleanup: Correct — this is redundant for bool args in clap.
  • universaldb::prelude::* glob import: Acceptable for a prelude module; the restriction in CLAUDE.md is specific to anyhow.

@MasterPtato MasterPtato force-pushed the 02-25-chore_add_log_for_runners_with_no_alloc_idx branch from 5e58e8c to a9c0244 Compare February 27, 2026 00:12
@MasterPtato MasterPtato force-pushed the 02-26-fix_add_serverless_leak_fix_oneoff branch from 8839aa5 to 61a6e04 Compare February 27, 2026 00:12
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

More templates

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4318

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4318

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4318

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4318

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4318

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4318

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4318

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4318

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4318

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4318

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4318

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4318

commit: 61a6e04

Base automatically changed from 02-25-chore_add_log_for_runners_with_no_alloc_idx to main February 27, 2026 00:31
@NathanFlurry NathanFlurry force-pushed the 02-26-fix_add_serverless_leak_fix_oneoff branch from 61a6e04 to 5f5799b Compare February 27, 2026 00:31
@NathanFlurry NathanFlurry merged commit f335eab into main Feb 27, 2026
6 of 10 checks passed
@NathanFlurry NathanFlurry deleted the 02-26-fix_add_serverless_leak_fix_oneoff branch February 27, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants