Page MenuHomePhabricator

[keyserver] Remove holders in thread deleters
ClosedPublic

Authored by bartek on Sep 30 2024, 3:15 AM.
Tags
None
Referenced Files
F3514355: D13513.id44666.diff
Sun, Dec 22, 4:27 AM
F3513976: D13513.diff
Sun, Dec 22, 2:54 AM
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
Subscribers
None

Details

Summary

Address ENG-9354.
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 D13512

Test Plan

Enabled blob-hosted avatars for thin threads. Created a thread and set image avatar. Then deleted the thread. Looked into blob service logs to see that a blob was uploaded, then its holder was removed

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Sep 30 2024, 4:25 AM
bartek added inline comments.
keyserver/src/deleters/thread-deleters.js
103 ↗(On Diff #44666)
166–169 ↗(On Diff #44666)
ashoat added inline comments.
keyserver/src/deleters/thread-deleters.js
87–92 ↗(On Diff #44666)

Before landing, please update to:

const blobHolders = await fetchThreadBlobHoldersToDelete(threadIDs);
await removeBlobHolders(blobHolders);

const [{ threadInfos: serverThreadInfos }] = await Promise.all([
  fetchServerThreadInfos({ threadIDs: new Set(threadIDs) }),
  rescindPushNotifs(
    SQL`n.thread IN (${threadIDs})`,
    SQL`IF(m.thread IN (${threadIDs}), NULL, m.thread)`,
  ),
]);

const time = Date.now();
const updateDatas = [];
for (const containedThreadID of threadIDs) {
  for (const memberInfo of serverThreadInfos[containedThreadID].members) {
    updateDatas.push({
      type: updateTypes.DELETE_THREAD,
      userID: memberInfo.id,
      time,
      threadID: containedThreadID,
    });
  }
}

const [{ viewerUpdates }] = await Promise.all([
  createUpdates(updateDatas, { viewer, updatesForCurrentSession: 'return' }),
  deleteThreadsFromDB(threadIDs),
]);

(We want to call removeBlobHolders before mutating anything, so that if it fails we don't end up in an inconsistent state.)

166–169 ↗(On Diff #44666)

Before landing, please update to:

await removeBlobHolders(blobHolders);
await deleteThreadsFromDB(containerIDs);
This revision is now accepted and ready to land.Sep 30 2024, 5:39 AM