Page MenuHomePhabricator

[keyserver] Remove holders in upload deleters
ClosedPublic

Authored by bartek on Sep 30 2024, 3:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 11:35 AM
Unknown Object (File)
Thu, Dec 19, 11:34 AM
Unknown Object (File)
Thu, Dec 19, 11:34 AM
Unknown Object (File)
Fri, Nov 22, 4:32 PM
Unknown Object (File)
Fri, Nov 22, 4:32 PM
Unknown Object (File)
Nov 2 2024, 6:33 PM
Unknown Object (File)
Nov 2 2024, 6:31 PM
Unknown Object (File)
Nov 2 2024, 6:27 PM
Subscribers
None

Details

Summary

Address ENG-9352.
Before calling DELETE FROM uploads, we need to select the extra column first and remove blob holders if present in the column JSON.

Depends on D13511

Test Plan

Used local Blob Service for testing.

For deleteUpload, used the delete_upload keyserver endpoint (easy way is canceling media message on web, with blob uploads enabled). Called the endpoint and verified that blob associated with the upload was deleted from DDB.

For deleting unassigned uploads: Manually modified MariaDB by setting containers to null and age to be older than 24h. Modified the cron job call to instead run during keyserver startup. Verified that holders were removed.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Sep 30 2024, 4:18 AM
bartek added inline comments.
keyserver/src/deleters/upload-deleters.js
76

Not sure how to handle failures for removeBlobHolders (HTTP call). Possible approaches:

  • Ignore failures (ignorePromiseRejections) - might results in orphaned blobs
  • Wait with DELETE for the holders request to succeed - the operation fails but they're still in DB so can be retried
  • Store failed holders somewhere for later retry

Besides, the removeBlobHolders() could potentially perform a retry-with-backoff

keyserver/src/deleters/upload-deleters.js
76

My instinct is that this solution:

Wait with DELETE for the holders request to succeed - the operation fails but they're still in DB so can be retried

Is the easiest one here

ashoat added inline comments.
keyserver/src/deleters/upload-deleters.js
76

Before landing, please update to:

const holdersQuery = SQL`
  SELECT extra
  FROM uploads
  WHERE container IS NULL
    AND user_container IS NULL
    AND creation_time < ${oldestUnassignedUploadToKeep}
`;
const [rows] = await dbQuery(holdersQuery);
const blobHolders = blobHoldersFromUploadRows(rows);
await removeBlobHolders(blobHolders);

const deletionQuery = SQL`
  DELETE u, i
  FROM uploads u
  LEFT JOIN ids i ON i.id = u.id
  WHERE u.container IS NULL
    AND u.user_container IS NULL
    AND creation_time < ${oldestUnassignedUploadToKeep}
`;
await dbQuery(deletionQuery);
This revision is now accepted and ready to land.Sep 30 2024, 5:36 AM