Skip to content

fix(server): enforce live storage reservation entitlement before delayed unpaid uploads - #1357

Open
harrymove-ctrl wants to merge 1 commit into
devfrom
fix/server-upload-reservation-entitlement
Open

harrymove-ctrl wants to merge 1 commit into
devfrom
fix/server-upload-reservation-entitlement

Conversation

@harrymove-ctrl

Copy link
Copy Markdown
Collaborator

Summary

  • Gate UPDATE storage_reservations in keep_upload_storage_reservation and ensure_upload_storage_reservation_with_db with WHERE id = $1 AND expires_at > NOW() so an expired reservation that has not been swept yet cannot be resurrected in place without re-checking the owner's storage quota under the advisory lock (pg_advisory_xact_lock).
  • Add ensure_upload_storage_reservation_with_db and call it in execute_durable_upload before any unpaid sidecar upload step (!upload_journal_signer_committed(&journal) && journal.register_transaction.is_none()).
  • Abort unpaid upload jobs permanently with WalletJobError::Permanent when their reservation expired and re-admission via try_admit_storage reports StorageAdmission::QuotaExceeded, while preserving post-payment recovery (register_transaction.is_some() or signer-committed journals) for blobs that already consumed WAL/gas.
  • Add expired_reservation_cannot_resurrect_or_upload_past_owner_quota in services/server/src/storage/db.rs covering both swept and unswept expired reservations, over-quota rejection, and within-quota re-admission.

Test Plan

  • DATABASE_URL="postgresql://memwal:memwal_secret@localhost:5432/memwal" cargo test --lib quota_admission_tests (4 passed)
  • cargo test --lib jobs::tests (90 passed)

@harrymove-ctrl
harrymove-ctrl requested a review from ducnmm October 29, 2026 10:03
@harrymove-ctrl

Copy link
Copy Markdown
Collaborator Author

@ducnmm This PR is ready for review at commit 302e9a1. All 22/22 CI checks are passing.

This branch has not been deployed

No deployments
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