Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(replicator): Replicator stops updating with many "foreign key constraint" errors #1556

Closed
cameronvoell opened this issue Nov 3, 2023 · 11 comments
Labels
s-triage Needs to be reviewed, designed and prioritized

Comments

@cameronvoell
Copy link

cameronvoell commented Nov 3, 2023

What is the bug?

Replicator stopped updating last night (querying db missing data for last 15hours or so). Checking on the server the replicator process was logging many errors:
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"

How can it be reproduced? (optional)

Hub and Replicator both launched using the install scripts on the same Digital Ocean ubuntu 22.04 server about 3 days ago, so should have been version Hub Release 1.7.0 for both.

Hubble Dashboard wasn't showing anything unusual. Replicator redis WebUI (script defaults to port 9000) was showing ~300+ delayed jobs that all showed the same "foreign key constraint" error.

Not an urgent blocker as I was able to get it syncing again. => To attempt to clear up the issue I clicked "clean all" in the Delayed section of the Replicator Web UI. This didnt seem to fix it. I then brought hubble and replicator down via their scripts, and then brought them back up and at that point the replicator started syncing and appears to up to date again. Though the Replicator Web UI does still show ~40 of the "foreign key constraint" errors in the "Delayed" column.

Additional context (optional)

See Warpcast thread of myself(@cyrcus) and @haole discussing as we both ran into the error => https://warpcast.com/haole/0x89b9f44b

Screenshot of Replicator Redis UI:
image

See delayed job error logs below:

ProcessHubEvent Error

Data:

{
  "data": {
    "hubEventJsonStr": "{\"type\":\"HUB_EVENT_TYPE_MERGE_MESSAGE\",\"id\":366630771179520,\"mergeMessageBody\":{\"message\":{\"data\":{\"type\":\"MESSAGE_TYPE_REACTION_ADD\",\"fid\":680,\"timestamp\":89486665,\"network\":\"FARCASTER_NETWORK_MAINNET\",\"reactionBody\":{\"type\":\"REACTION_TYPE_LIKE\",\"targetCastId\":{\"fid\":4163,\"hash\":\"VC+AAXFsvIxZVNzuq8l2vEIk6uE=\"}}},\"hash\":\"rQn98rxbgWI8JTK0fw+WvKoZLUE=\",\"hashScheme\":\"HASH_SCHEME_BLAKE3\",\"signature\":\"1yIVNQPNrgg4WEP+s6tvkXS3od8Aur80PngXZk7H4SdCWemSlKFo4SmFZoTJZe5JeUaAHMMHkhkFBRtC77D2Cg==\",\"signatureScheme\":\"SIGNATURE_SCHEME_ED25519\",\"signer\":\"sLPssdYagY3ui5gxFBDrfUr0nO3/Vay7mTrSXeESM4Q=\"},\"deletedMessages\":[]}}"
  },
  "returnValue": null
}

Error:

error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:40:40.208Z',
    '2023-11-02T23:40:40.208Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:40:40.208Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:40:41.278Z',
    '2023-11-02T23:40:41.278Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:40:41.278Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:40:43.399Z',
    '2023-11-02T23:40:43.399Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:40:43.399Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:40:47.447Z',
    '2023-11-02T23:40:47.447Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:40:47.447Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:40:55.512Z',
    '2023-11-02T23:40:55.512Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:40:55.512Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:41:11.563Z',
    '2023-11-02T23:41:11.563Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:41:11.563Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:41:43.622Z',
    '2023-11-02T23:41:43.622Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:41:43.622Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:42:47.667Z',
    '2023-11-02T23:42:47.667Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:42:47.667Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:44:55.708Z',
    '2023-11-02T23:44:55.708Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:44:55.708Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:49:11.983Z',
    '2023-11-02T23:49:11.983Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:49:11.983Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
error: insert or update on table "messages" violates foreign key constraint "messages_signer_fid_foreign"
    at /home/node/app/node_modules/pg/lib/client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at PostgresConnection.executeQuery (/home/node/app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/node/app/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28
    at async #run (/home/node/app/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)
    at execute (/home/node/app/apps/replicator/build/db.js:129:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async storeMessage (/home/node/app/apps/replicator/build/processors/index.js:197:5)
    at async processMessage (/home/node/app/apps/replicator/build/processors/index.js:70:5)
    at async mergeMessage (/home/node/app/apps/replicator/build/processors/index.js:52:5)
    at async /home/node/app/apps/replicator/build/processors/index.js:289:9
    at async /home/node/app/apps/replicator/build/db.js:156:20
    at async /home/node/app/node_modules/kysely/dist/cjs/kysely.js:418:32
    at async DefaultConnectionProvider.provideConnection (/home/node/app/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
    at async executeTx (/home/node/app/apps/replicator/build/db.js:155:16)
insert into
  "messages" (
    "created_at",
    "updated_at",
    "fid",
    "type",
    "timestamp",
    "hash",
    "hash_scheme",
    "signature",
    "signature_scheme",
    "signer",
    "raw",
    "deleted_at",
    "pruned_at",
    "revoked_at",
    "body"
  )
values
  (
    '2023-11-02T23:57:44.049Z',
    '2023-11-02T23:57:44.049Z',
    680,
    1,
    '2023-11-02T19:34:53.000Z',
    '\x8f85ffd908b9dc8eb5b13751761f03ae858e257f',
    1,
    '\x826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a02',
    1,
    '\xb0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    '\x0a2d080110a80518dda7d62a20012a1f12001a1908bf01121428368a8e258bb9062dbea5009d1ea97cdbf04e522a0012148f85ffd908b9dc8eb5b13751761f03ae858e257f18012240826f27434b70f2a5e45c9a8eceee5fbe19f7b8ce797bc83604a759373c4bded5987fbddaa3ba6141a3b6c5a1909de1f6f5acd9082b1b85eb39f2451a1b017a0228013220b0b3ecb1d61a818dee8b98311410eb7d4af49cedff55acbb993ad25de1123384',
    null,
    null,
    null,
    '{"embeds":[],"mentions":[],"mentionsPositions":[],"text":"","parentCastId":{"fid":191,"hash":"0x28368a8e258bb9062dbea5009d1ea97cdbf04e52"}}'
  )
on conflict ("hash") do
update
set
  "updated_at" = '2023-11-02T23:57:44.049Z',
  "signature" = "excluded"."signature",
  "signature_scheme" = "excluded"."signature_scheme",
  "signer" = "excluded"."signer",
  "deleted_at" = null,
  "pruned_at" = null,
  "revoked_at" = null
where
  (
    "excluded"."signature" != "messages"."signature"
    or "excluded"."signature_scheme" != "messages"."signature_scheme"
    or "excluded"."signer" != "messages"."signer"
    or "excluded"."deleted_at" is distinct from "messages"."deleted_at"
    or "excluded"."pruned_at" is distinct from "messages"."pruned_at"
    or "excluded"."revoked_at" is distinct from "messages"."revoked_at"
  )
returning
  "hash",
  "updated_at",
  "created_at"
    at executeTx (/home/node/app/apps/replicator/build/db.js:161:50)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processMergeMessageHubEvent (/home/node/app/apps/replicator/build/processors/index.js:288:5)
    at async processHubEvent (/home/node/app/apps/replicator/build/processors/index.js:247:13)
    at async Object.run (/home/node/app/apps/replicator/build/jobs/processHubEvent.js:11:9)
    at async /home/node/app/node_modules/bullmq/dist/cjs/classes/child-processor.js:69:33
@github-actions github-actions bot added the s-triage Needs to be reviewed, designed and prioritized label Nov 3, 2023
@ethisscam
Copy link

You can remove the foreign key constraint from the messages table and check whether it starts syncing.
ALTER TABLE messages DROP CONSTRAINT messages_signer_fid_foreign;

@christopherwxyz
Copy link
Contributor

+1, i'm also having this same issue.

@sanjayprabhu
Copy link
Contributor

This is likely due to the replicator missing certain hub events. #1553 should reduce the likelihood of this happening, but real fix is to retry the missing on chain event if this is detected. Will fix.

@Bijan-Massoumi
Copy link

Bijan-Massoumi commented Nov 4, 2023

+1, i'm also having this same issue. Any workaround you recommend until this gets fixed?

I've tried pinning both my replicator and hub to 1.6.6 and syncing a fresh DB blasts my console output with these types of Errors

edit 1: I flushed my local redis and restarted and now it seems to be syncing. This bug could be caused by the fact that i switched DBs and hub instances without clearing my redis?

edit 2 ok now im having the same issue as OP

@Bijan-Massoumi
Copy link

any update on this? @sanjayprabhu

@sanjayprabhu
Copy link
Contributor

@Bijan-Massoumi Are you still seeing this issue after upgrading to the latest version?

@obo20
Copy link

obo20 commented Feb 7, 2024

@sanjayprabhu We're still seeing this issue (heavily) as of yesterday. Running hubble 1.9.8.

@namanjain
Copy link

@sanjayprabhu I'm also seeing this error pretty heavily at this point. Backfill is pretty much stuck at Backfilled events for 333607 of 333666 FIDs and the dashboard show 226 delayed jobs. The delayed jobs don't clear up after promoting and go back to delayed, which I assume is because of the foreign key errors.

@obo20
Copy link

obo20 commented Feb 21, 2024

An update on the pinata side, we did a fresh start of a new hub / replicator and immediately removed the foreign key constraints. From what we're seeing:

  • everything seems to be syncing up properly in near real time.
  • we seem to have the most "complete" dataset out of any attempts so far

@sanjayprabhu do you see any issues with this approach?

@sds
Copy link
Member

sds commented Mar 14, 2024

Hey all, wanted to explain what we currently believe is happening here.

A core assumption we made with the Replicator's design was that it should not process messages which refer to other messages/data that are missing. Hubs don't strictly follow this rule—a message can be valid even if it refers to another message that doesn't yet exist on the hub.

Two simple examples of this are:

  • Don't process a cast reply if its author's FID does not yet exist
  • Don't process a cast reply if its parent's cast does not yet exist

Similar situations apply for reactions, links, etc. Behavior is documented here, but we will call this out more clearly in the README:

* Declares foreign keys to ensure correctness. This means that the replicator will not process
a message if it refers to content that has not yet been seen, since that would violate the FK
constraint. Instead, it will put the message into an unprocessed message queue and try again
once the content it references has been processed. If you want to remove data that was
pruned/revoked/deleted, you can hard delete the corresponding row in the messages table, and
the downstream tables referencing that message will also be deleted.

The reason enforcing foreign key constraints are helpful in this context is that it can help find legitimate bugs (whether its due to missing FIDs from a lost event or something else)! However, for some purposes disabling them can be helpful in the short term, but I would not consider it a long-term solution—it's just masking the problem.

We're giving a lot of thought to the current Replicator design. We hope to share more on the path forward soon.

Another advantage to using foreign keys is that when you want to delete pruned/revoked/deleted messages, the constraints will automatically cascade the deletes with no additional application logic required by you.

@sds
Copy link
Member

sds commented Jun 3, 2024

We now recommend you use the Shuttle package instead of the old replicator.

@sds sds closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s-triage Needs to be reviewed, designed and prioritized
Projects
None yet
Development

No branches or pull requests

8 participants