CounterpartyXCP / counterparty-core

Counterparty Protocol Reference Implementation
http://counterparty.io
MIT License
282 stars 206 forks source link

`UNIQUE constraint failed: transactions.tx_hash` #1952

Open adamkrellenstein opened 2 months ago

adamkrellenstein commented 2 months ago
ERROR:root:SQLITE_LOG: abort at 56 in [INSERT INTO transactions (tx_index, tx_hash, block_index, block_hash, block_time, source, destination, btc_amount, fee, data) VALUES (:tx_index, :tx_hash, :block_index, :block_hash, :block_time (2067) SQLITE_CONSTRAINT_UNIQUE
2024-06-19T20:26:34.324625000+00:00 - [   ERROR] - Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 194, in handle
    await self.receive_multipart(self.zmq_sub_socket_sequence, "sequence")
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 188, in receive_multipart
    self.receive_message(topic, body, seq)
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 179, in receive_message
    self.receive_sequence(body)
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 158, in receive_sequence
    mempool.parse_mempool_transactions(self.db, self.mempool_block)
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/mempool.py", line 33, in parse_mempool_transactions
    mempool_tx_index = blocks.list_tx(
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/blocks.py", line 865, in list_tx
    ledger.insert_record(db, "transactions", transaction_bindings, "NEW_TRANSACTION")
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/ledger.py", line 27, in insert_record
    cursor.execute(query, record)
  File "src/cursor.c", line 169, in resetcursor
apsw.ConstraintError: ConstraintError: UNIQUE constraint failed: transactions.tx_hash

This has been reported with v10.2.0 but not with v10.1.0. A restart fixes the issue temporarily.

ImagiNFT commented 2 months ago

once again happened pasting here the log if helps:

2024-06-26T10:15:59.871793000+00:00 - [   DEBUG] - API Status Poller - Backend state check passed.
2024-06-26T10:16:00.529612000+00:00 - [    INFO] - Block 849548
2024-06-26T10:16:00.678535000+00:00 - [    INFO] - Block 849548 - Closing dispenser for FAKEASF at 1BnERLy3 in 5 blocks (6149a37) [valid]
2024-06-26T10:16:00.679321000+00:00 - [    INFO] - Block 849548 - Parsing complete. L: 3f7e1cf, TX: ead4d6a, M: 5b81746 (0.15s)
2024-06-26T10:16:00.679847000+00:00 - [   DEBUG] - Cleaning mempool...
2024-06-26T10:16:02.276788000+00:00 - [   DEBUG] - Parsing 100 raw transactions from mempool...
ERROR:root:SQLITE_LOG: abort at 56 in [INSERT INTO transactions (tx_index, tx_hash, block_index, block_hash, block_time, source, destination, btc_amount, fee, data) VALUES (:tx_index, :tx_hash, :block_index, :block_hash, :block_time (2067) SQLITE_CONSTRAINT_UNIQUE
2024-06-26T10:16:02.286706000+00:00 - [   ERROR] - Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 194, in handle
    await self.receive_multipart(self.zmq_sub_socket_sequence, "sequence")
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 188, in receive_multipart
    self.receive_message(topic, body, seq)
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 179, in receive_message
    self.receive_sequence(body)
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/follow.py", line 158, in receive_sequence
    mempool.parse_mempool_transactions(self.db, self.mempool_block)
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/mempool.py", line 33, in parse_mempool_transactions
    mempool_tx_index = blocks.list_tx(
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/blocks.py", line 865, in list_tx
    ledger.insert_record(db, "transactions", transaction_bindings, "NEW_TRANSACTION")
  File "/usr/local/lib/python3.10/dist-packages/counterpartycore/lib/ledger.py", line 27, in insert_record
    cursor.execute(query, record)
  File "src/cursor.c", line 169, in resetcursor
apsw.ConstraintError: ConstraintError: UNIQUE constraint failed: transactions.tx_hash

2024-06-26T10:16:02.286925000+00:00 - [    INFO] - Stopping blockchain watcher...
2024-06-26T10:16:02.287560000+00:00 - [    INFO] - Stopping API Server...
2024-06-26T10:16:03.290625000+00:00 - [    INFO] - Stopping telemetry daemon...
2024-06-26T10:16:03.314229000+00:00 - [    INFO] - Stopping API Status Poller...
2024-06-26T10:16:03.378745000+00:00 - [    INFO] - Stopping API Server v1...
2024-06-26T10:16:03.621577000+00:00 - [    INFO] - Stopping blockchain watcher...
2024-06-26T10:16:03.622483000+00:00 - [    INFO] - Closing database connections...
2024-06-26T10:16:03.647736000+00:00 - [    INFO] - Stopping AddrIndexRs thread...
2024-06-26T10:16:03.648029000+00:00 - [   DEBUG] - AddrindexRS Client - Server: `172.17.0.3:8432` - Disconnected
2024-06-26T10:16:04.631772000+00:00 - [    INFO] - Shutting down logging...
2024-06-26T10:16:04.633022000+00:00 - [    INFO] - Stopping fetcher...
2024-06-26T10:16:04.633863000+00:00 - [    INFO] - Shutdown complete.
ouziel-slama commented 2 months ago

fixed here https://github.com/CounterpartyXCP/counterparty-core/pull/1928/commits/5852ef52b5d0ab59670e234c89cc508ea8a5fd98

adamkrellenstein commented 1 month ago

https://counterparty.sentry.io/share/issue/63d8114215e3453597db34def13fd48c/