Skip to content

Run the state setter on every path reaching a committed manifest - #36

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
fix/content-session-starvation
Sep 18, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
fix/content-session-starvation

Conversation

@LucaCappelletti94

@LucaCappelletti94 LucaCappelletti94 commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Running the browser suites two-at-a-time on one stack, as the demo registration in pull request #34 does, exposed a deterministic stall: the first photo suite passed and every content suite after it hung forever waiting for content_state to flip. The cause is in the upload commit path. File identity is a hash of content bytes, so a second session staging identical bytes dedupes against the manifest a previous session committed; post_commit saw ManifestState::Committed, returned 200 and skipped connetto_set_content_state, but the caller's own metadata row for the same content, inserted in this session, was waiting on exactly that call. The relay hub took the 200 as done, no CDC event ever fired for the row, and the waiting tab hung until the test runner killed it. The fix re-runs the setter on the already-committed path; the setter updates by content_id and is idempotent for rows already at the target state.

The regression test in tests/it/upload.rs records every setter call against a replacement function, uploads once through the full intent, chunk and commit flow, then commits again on the committed manifest with a fresh ticket and asserts the setter ran for available with the right caller. It fails on main, passing run shows 1 passed in 6.2s, failing run shows the recorded count at zero, and passes with the fix. The browser-level proof is the exact CI adjacency that deterministically hung before this change, photo_offline then the yew demo photo suite on one shared stack, now green: SMOKE-PASS then YEW-PASS, 2 passed. fmt and clippy -D warnings --all-features --tests are clean for connetto-file-server.

Summary by Sourcery

Re-run the content state setter whenever a commit targets an already-committed manifest so deduplicated sessions complete reliably.

Bug Fixes:

  • Ensure recommits of already-committed manifests update metadata rows created by subsequent upload sessions, preventing content-state waits from hanging.

Tests:

  • Add an integration regression test covering deduplicated uploads and verifying the state setter is invoked on a committed-manifest recommit.

@sourcery-ai sourcery-ai 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.

Sorry @LucaCappelletti94, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: LucaCappelletti94/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: e69b860a-5f94-4b9e-9f1d-8af44f435f24


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-18T17:13:05.098110Z 8e38ead PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The upload commit path now re-runs the idempotent content state setter on already committed manifests, preventing metadata rows created by later deduplicated sessions from hanging indefinitely; an integration test verifies the behavior with a fresh ticket and recorded setter invocation.

Sequence diagram for re-committing a deduplicated manifest

sequenceDiagram
    participant Session1
    participant Session2
    participant UploadAPI
    participant Database
    participant StateSetter
    participant RelayHub

    Session1->>UploadAPI: post_commit
    UploadAPI->>Database: load_manifest_locked
    Database-->>UploadAPI: Uncommitted manifest
    UploadAPI->>StateSetter: connetto_set_content_state(content_id, available, caller)
    StateSetter->>Database: UPDATE metadata by content_id
    StateSetter-->>UploadAPI: success
    UploadAPI-->>Session1: 200 OK

    Session2->>UploadAPI: post_commit with fresh ticket
    UploadAPI->>Database: load_manifest_locked
    Database-->>UploadAPI: Committed manifest
    UploadAPI->>StateSetter: connetto_set_content_state(content_id, available, caller)
    StateSetter->>Database: UPDATE later-session metadata
    StateSetter-->>UploadAPI: success
    UploadAPI-->>Session2: 200 OK
    Database-->>RelayHub: CDC state update
    RelayHub-->>Session2: content_state available
Loading

Flow diagram for committed manifest state handling

flowchart TD
    A[post_commit] --> B[load_manifest_locked]
    B --> C{Manifest state}
    C -->|Uncommitted| D[verify_file_identity]
    D --> E[connetto_set_content_state]
    E --> F[200 OK]
    C -->|Committed| G[connetto_set_content_state]
    G --> H[200 OK]
    H --> I[Update metadata by content_id]
Loading

File-Level Changes

Change Details Files
Re-run the content state setter when committing an already committed manifest.
  • Detect the committed-manifest retry path inside the transaction.
  • Invoke the idempotent setter by content ID with the requested target state and caller before returning 200.
  • Import the async Diesel query trait needed to execute the setter function.
crates/connetto-file-server/src/upload.rs
Add an integration regression test for cross-session deduplicated recommits.
  • Complete an initial intent, chunk upload, and commit flow.
  • Create a fresh session for identical content and commit against the already committed manifest.
  • Replace the setter with a recording database function and assert one available-state call for the expected file and caller.
crates/connetto-file-server/tests/it/upload.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.24%. Comparing base (f2b69ee) to head (2a5ad5e).

Files with missing lines Patch % Lines
crates/connetto-file-server/src/upload.rs 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage   83.24%   83.24%           
=======================================
  Files         114      114           
  Lines       25693    25700    +7     
  Branches    25693    25700    +7     
=======================================
+ Hits        21388    21395    +7     
+ Misses       3079     3078    -1     
- Partials     1226     1227    +1     
Flag Coverage Δ
client 64.16% <ø> (ø)
rest 56.37% <87.50%> (+<0.01%) ⬆️
server 48.78% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the fix/content-session-starvation branch from 8e38ead to 2a5ad5e Compare September 18, 2026 18:09
@sonarqubecloud

Copy link
Copy Markdown

@LucaCappelletti94
LucaCappelletti94 merged commit 9eb3c26 into main Sep 18, 2026
59 of 60 checks passed
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.

1 participant