Page MenuHomePhabricator

[keyserver] Remove holders in thread deleters
ClosedPublic

Authored by bartek on Sep 30 2024, 3:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 2, 6:33 PM
Unknown Object (File)
Sat, Nov 2, 6:31 PM
Unknown Object (File)
Sat, Nov 2, 6:27 PM
Unknown Object (File)
Fri, Nov 1, 5:35 AM
Unknown Object (File)
Wed, Oct 30, 10:28 AM
Unknown Object (File)
Tue, Oct 29, 3:22 PM
Unknown Object (File)
Fri, Oct 25, 4:22 PM
Unknown Object (File)
Tue, Oct 22, 7:26 AM
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