Page MenuHomePhabricator

[keyserver] Remove holders in thread deleters
ClosedPublic

Authored by bartek on Mon, Sep 30, 3:15 AM.
Tags
None
Referenced Files
F2874387: D13513.id44817.diff
Thu, Oct 3, 2:11 AM
F2873058: D13513.diff
Wed, Oct 2, 11:26 PM
Unknown Object (File)
Tue, Oct 1, 12:03 AM
Unknown Object (File)
Tue, Oct 1, 12:02 AM
Unknown Object (File)
Mon, Sep 30, 11:59 PM
Unknown Object (File)
Mon, Sep 30, 5:29 PM
Unknown Object (File)
Mon, Sep 30, 1:43 PM
Unknown Object (File)
Mon, Sep 30, 12:51 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.Mon, Sep 30, 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.Mon, Sep 30, 5:39 AM