Page MenuHomePhabricator

[keyserver/lib] update deleteFarcasterChannelTag to use communites table
AcceptedPublic

Authored by ginsu on Thu, May 9, 11:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 18, 4:18 PM
Unknown Object (File)
Fri, May 17, 8:20 PM
Unknown Object (File)
Thu, May 16, 6:48 PM
Unknown Object (File)
Wed, May 15, 10:10 AM
Unknown Object (File)
Tue, May 14, 12:03 PM
Unknown Object (File)
Mon, May 13, 2:01 PM
Unknown Object (File)
Fri, May 10, 4:23 AM
Unknown Object (File)
Fri, May 10, 4:22 AM
Subscribers

Details

Reviewers
tomek
kamil
Summary

Now that we have a communities table that was introduced in D11903, we can use it to better improve our deleteFarcasterChannelTag method

Depends on D11975

Test Plan

Removed the farcaster channel tag and confirmed that the farcaster channel id and the blob holder were removed in the correct row of the communites table + also confirmed that the blob holding the farcaster channel <> comm community association was deleted

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

keyserver/src/deleters/farcaster-channel-tag-deleters.js
29–34

Initially tried to use RETURNING blob_holder AS blobHolder as part of the query (just like in deleteInviteLink); however, was getting a You have an error in your SQL syntax; error so created a separate query to get the blob holder and now everything works as expected

lib/types/community-types.js
31

Initially we were passing the blobHolder as part of the request since the blob holder was temporarily stored in redux; however, now that we can store the blobHolder in the communities table on the keyserver, the blob holder should never be in the client so we should remove it as part of the request

ginsu requested review of this revision.Thu, May 9, 11:16 AM
tomek added inline comments.
keyserver/src/deleters/farcaster-channel-tag-deleters.js
29–34

It seems like MariaDB doesn't support RETURNING with UPDATE statements https://mariadb.com/kb/en/update/.

I can see some problems with the current implementation:

  1. Is it guaranteed that the select will happen before the update?
  2. Are we sure that the rows can't be modified before select and update?

There are at least 3 possible solutions:

  1. We can consider using https://mariadb.com/kb/en/replace/
  2. Maybe transactions can help with this
  3. Maybe it is possible to delete and insert instead of update

The chance for this edge case is really low, so we should decide if we really care about it.

This revision is now accepted and ready to land.Fri, May 10, 4:15 AM