superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.67k stars 310 forks source link

[bug] Inbox post returns bad request: `enrichAccount: error putting in database: already exists` #1548

Closed tsmethurst closed 1 year ago

tsmethurst commented 1 year ago

Seeing a few of these bad boys logged with no apparent cause, this issue is a stub to remind myself (or someone else) to investigate it, we're probably dropping messages because of it.

NyaaaWhatsUpDoc commented 1 year ago

this will be a race condition with multiple codepaths going down the same path of enriching a new account model I'm pretty sure. I have an idea of how to fix this though I'm hesitant as without a deep dive into how the go-fed/activity library is using the per URI locking we could end up deadlocking against that. I'll have to take a deeper look when I next get a chance.

NyaaaWhatsUpDoc commented 1 year ago

a cheap fix for now would be to just do if errors.Is(err, db.ErrAlreadyExists() on the new account route (i.e. account.CreatedAt.IsZero()) and in that case do a re-fetch from database for the newly stored item.

it's not the neatest method and means we could be doing multiple derefs for things at a time, but it would work for now.

tsmethurst commented 1 year ago

closed by https://github.com/superseriousbusiness/gotosocial/pull/1581