Skip to content

Retried delivery records an expiry Drive does not hold #665

Open

Description

@jserv

Observed behavior

When a recording delivery is retried after the Drive share already succeeded, the deadline the row records can be later than the expiry Drive holds. The candidate's access then ends before the date the row and the status route report.

The sequence at 55597864:

  1. Attempt one computes expires_at = clock.now() + retention_seconds and shares the file through Drive with it (src/recording/transfer.rs:38-40), and share_file stores the permission id (src/recording/transfer.rs:257).
  2. The write that marks the delivery finished fails, so the delivery is rescheduled.
  3. Attempt two computes a new expires_at from the clock. share_file finds uploaded.existing_permission and makes no second share call, so Drive keeps the first expiry. finish then records the new, later one (src/recording/transfer.rs:43).

The gap is the time between the two attempts: the retry backoff is 60 seconds after the first failure and 300 after the second (DELIVERY_BACKOFF_SECONDS), plus the time the second attempt spends before it reaches the share step.

Expected behavior

The recorded deadline equals the expiry the Drive permission holds. RETENTION_SECONDS in src/recording/queue.rs:213-216 says the permission and the deletion deadline have to be the same number or one of them is a lie.

Reproduction

Read from the code, not run.

  1. Deliver a recording with a Drive double that accepts the share and a database write that fails once in finish.
  2. Advance the clock by the retry backoff and run the queue again.
  3. Compare the permission's expirationTime in the double with recordings.expires_at: they differ by the elapsed time.

CodeTrial version

desktop-latest-25-g55597864

Environment

Not environment specific.

Sanitized evidence

None. The error is in the safe direction: access ends early, and the retention sweep deletes later than the access ended, so nothing stays readable longer than reported. The status route can show a deadline the candidate no longer has.

A fix needs the permission's expiry stored with its id, so a retry records what Drive holds. That is a schema change on the recordings table, so it needs a maintainer decision before code. The alternative is to read the expiry back from Drive on retry, which costs one more provider call per retried delivery and is subject to docs/provider-cost-and-degradation.md.

Public data confirmation

  • I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.

Activity

  1. Ezechungi7 commented on Nov 15, 2026

    @Ezechungi7
    Contributor

    I inspected src/recording/transfer.rs, src/recording/store.rs, src/recording/summary.rs, and src/accounts/schema.rs to compare the options for keeping recordings.expires_at equal to the Drive permission's expirationTime across retries, these are the possible solutions:

    1. Write expires_at alongside drive_permission_id in the existing recordings.expires_at column (no schema migration or extra Drive call):
      • set_drive_permission (src/recording/transfer.rs:552) can write SET drive_permission_id = ?2, expires_at = ?3 atomically when the share succeeds, and delivery_handles (src/recording/store.rs:482) can return the stored expires_at alongside drive_permission_id so a retry passes the existing expiry into finish_delivery (src/recording/transfer.rs:585).
      • due_for_deletion (src/recording/summary.rs:120) already filters state IN ('ready', 'failed', 'cleanup_failed'), so a transferring row is not swept early; if expires_at should also remain hidden on the status route (src/web/recordings/mod.rs:473) until finish_delivery marks the row ready, RecordingSummary can expose expires_at only once ready_at is set (or forget_drive_file can clear expires_at = NULL alongside drive_permission_id = NULL on a lost race).
    2. Add a separate drive_permission_expires_at INTEGER column (src/accounts/schema.rs):
      • set_drive_permission records (drive_permission_id, drive_permission_expires_at), forget_drive_file and Handle::DrivePermission (src/recording/store.rs:518) clear both, and recordings.expires_at stays NULL until finish_delivery copies drive_permission_expires_at into expires_at, at the cost of a schema migration in src/accounts/schema.rs.
    3. Read expirationTime back from Drive on retry (GET /drive/v3/files/{fileId}/permissions/{permissionId}?fields=expirationTime):
      • Avoids any schema change, but adds a network round-trip and provider quota spend on every retried delivery after share_file.

    Options 1 and 2 both avoid the extra Drive API call on retry. Is there any approach you lean more towards to?

  2. jserv commented on Nov 15, 2026

    @jserv
    ContributorAuthor

    Options 1 and 2 both avoid the extra Drive API call on retry. Is there any approach you lean more towards to?

    Option 1 looks good. You have to consolidate validation plans as well.

  3. added 13 commits that reference this issue on Nov 17, 2026
    2e8f7e4
    877dd26
    2287c7a
    ecbd56a
    3c735d8
    dbd65e0
    0e86922
    83a7f62
    13256f2
    c407c3d
    1e34250
    9fd8e28
    a305429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions