hirosystems / ordhook

Build indexers, standards and protocols on top of Ordinals and Inscriptions (BRC20, etc).
Apache License 2.0
174 stars 54 forks source link

Unable to insert inscription in hord.sqlite: UNIQUE constraint failed: inscriptions.inscription_id #293

Closed enjoooyer closed 1 month ago

enjoooyer commented 3 months ago

Version: v2.1.0

Getting the following warning when indexing

{
  "msg": "unable to insert inscription in hord.sqlite: UNIQUE constraint failed: inscriptions.inscription_id - OrdinalInscriptionRevealData { content_bytes: \"0x636272632d32303a6d696e743a4d4f544f42494b453d3230\", content_type: \"text/plain\", content_length: 24, inscription_number: OrdinalInscriptionNumber { classic: -154345, jubilee: 9171304 }, inscription_fee: 10152, inscription_output_value: 333, inscription_id: \"06e33f84aace60f1e1ca1bcaab3d702f4fb454f8f1cfdf6f1b53b5a9ee04d630i0\", inscription_input_index: 0, inscription_pointer: None, inscriber_address: Some(\"tb1qd8t2yg87a9nmqadn3aa4njrppzma5exwxemww3\"), delegate: None, metaprotocol: Some(\"cbrc-20:mint:MOTOBIKE=20\"), metadata: None, parent: None, ordinal_number: 1773075805193874, ordinal_block_height: 578460, ordinal_offset: 805193874, tx_index: 1, transfers_pre_inscription: 3013, satpoint_post_inscription: \"06e33f84aace60f1e1ca1bcaab3d702f4fb454f8f1cfdf6f1b53b5a9ee04d630:0:0\", curse_type: Some(Reinscription) }",
  "level": "WARN",
  "ts": "2024-04-23T10:46:49.381543498Z"
}

it's logged as a warning, but it seems to be an error as it kills the service.

No new inscriptions have been inserted after encountering this and applications hooking to the stream are no longer able to connect.

ordinals-api won't start up and it's logging connect ECONNREFUSED XXX.XX.X.XX:20456

Can it be fixed by a simple ON CONFLICT DO NOTHING here https://github.com/hirosystems/ordhook/blob/4a9e3360656a892ee756f2b5bd8fc8412cfc05fc/components/ordhook-core/src/db/mod.rs#L516 or does it indicate a bigger bug somewhere?

lgalabru commented 1 month ago

Hi @enjoooyer! I think this is indicating that you're either running an outdated version of Ordhook, or have an outdated snapshot. I would recommend to download the latest version of Ordhook (2.2.1) and download a backup that has been produced anytime after 06/10.

lgalabru commented 1 month ago

Feel free to reopen if you're still experiencing some issues.