farcasterxyz / hub-monorepo

Implementation of the Farcaster Hub specification and supporting libraries for building applications on Farcaster
https://www.thehubble.xyz
MIT License
707 stars 401 forks source link

message signed by a different user(fid) causes Replicator message inserts to fail #1585

Closed artlu99 closed 8 months ago

artlu99 commented 11 months ago

What is the bug? A valid message in Hub doesn't make it to Replicator Postgres, due to a construction that causes a Postgres foreign key constraint violation

How can it be reproduced? run Replicator backfill on FID 6806

Additional context cast URL: Dawufi 2023-11-11 cast hash: 0xeada968d520acc83c74c5c480647c705eef1d8f9

diagnosis: Dawufi's cast was signed by Conor @nor for Negation Game

error message:

ERROR ([mmmm]): Job BackfillFidCasts [nnnn] failed: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign": error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at [path]/hub-monorepo/node_modules/pg/lib/client.js:526:17
sds commented 11 months ago

Which version of the hub were you running, @artlu99?

The likely cause is that the hub the replicator was syncing from missed an on-chain event, which means that the signer data wasn't created in Postgres, leading to the constraint violation.

This should be fixed by syncing on-chain events via the sync trie, which I don't believe has been enabled yet. Even so, you'll still occasionally see these errors, but they will eventually self-resolve. If you're seeing these errors forever, then there's a bug.

artlu99 commented 10 months ago

thanks @sds.

my replicator has been run multiple times against nemes, neynar, and standardcrypto hubs, with versions ranging from 1.7.2 to 1.8.0.

I'm seeing this category of errors appear forever (that is, for several weeks).

Is there a way to further identify whether it's a simple sync issue, or another bug?

web123pro commented 9 months ago

Running into the same issue. Is there a fix for this ?

sds commented 8 months ago

Sorry for the delay in response. Since this issue was opened, we've fixed some core bugs in the sync implementation for hubs. If you're still seeing this with the latest version of hubs (1.10.9 at time of writing) please do open a new issue!