Setting psql-index-threshold to 1 and restart causes errors
- Run HAF to live sync in docker (using example_deployment docker compose scripts) using this version of HAF: 58757585
- Shut down stack.
- Add balance_tracker (needs this mr to work), start and run for a short time (maybe 5 minutes)
- shut down again
- Edit config.ini, set
psql-index-threshold
to 1, restart stack
haf dies with this exception:
std::exception::what: ERROR: update or delete on table "events_queue" violates foreign key constraint "fk_hive_app_context" on table "contexts"
DETAIL: Key (id)=(148759) is still referenced from table "contexts".
CONTEXT: SQL statement "DELETE FROM hive.events_queue heq
USING ( SELECT MIN( hc.events_id) as id FROM hive.contexts hc ) as min_event
WHERE ( heq.id < __upper_bound_events_id OR __upper_bound_events_id IS NULL ) AND ( heq.id < min_event.id OR min_event.id IS NULL ) AND heq.id != 0 AND heq.id != hive.unreachable_event_id()"
PL/pgSQL function hive.remove_unecessary_events(integer) line 27 at SQL statement
SQL statement "SELECT hive.remove_unecessary_events( _block_num )"
PL/pgSQL function hive.set_irreversible(integer) line 9 at PERFORM
- change
psql-index-threshold
back to 1000000, restart stack
this time, haf dies with a different exception
rocessor: hive.set_irreversible caller...
2023-08-18T17:19:20.956022 data_processor.cpp:187 join ] Data processor: hive.set_irreversible caller resumed...
2023-08-18T17:19:20.956115 data_processor.cpp:194 join ] Caught unhandled exception Dynamic exception type: pqxx::unique_violation
std::exception::what: ERROR: duplicate key value violates unique constraint "pk_hive_operations"
DETAIL: Key (id)=(4936509245) already exists.
CONTEXT: SQL statement "INSERT INTO hive.operations
SELECT
hor.id
, hor.block_num
, hor.trx_in_block
, hor.op_pos
, hor.op_type_id
, hor.timestamp
, hor.body_binary
FROM
hive.operations_reversible hor
JOIN (
SELECT
DISTINCT ON ( hbr.num ) hbr.num
, hbr.fork_id
FROM hive.blocks_reversible hbr
WHERE
hbr.num <= _new_irreversible_block
AND hbr.num > _head_block_of_irreversible_blocks
ORDER BY hbr.num ASC, hbr.fork_id DESC
) as num_and_forks ON hor.block_num = num_and_forks.num AND hor.fork_id = num_and_forks.fork_id"
PL/pgSQL function hive.copy_operations_to_irreversible(integer,integer) line 3 at SQL statement
SQL statement "SELECT hive.copy_operations_to_irreversible( __irreversible_head_block, _block_num )"
PL/pgSQL function hive.set_irreversible(integer) line 18 at PERFORM
2023-08-18T17:19:20.956170 data_processor.cpp:185 join ] Trying to resume data processor: hive.back_from_fork caller...
2023-08-18T17:19:20.956189 data_processor.cpp:187 join ] Data processor: hive.back_from_fork caller resumed...
haf_block_log=# select * from hive.contexts;
id | name | current_block_num | irreversible_block | is_attached | back_from_fork | events_id | fork_id | owner | detached_block_num | registering_state_provider | is_forking
----+--------------+-------------------+--------------------+-------------+----------------+---------------------+---------+---------------+--------------------+----------------------------+------------
1 | btracker_app | 756198 | 77616347 | f | f | 9223372036854775807 | 13 | haf_app_admin | | f | t
(1 row)
haf_block_log=# select * from hive.events_queue where id = 9223372036854775807;
id | event | block_num
---------------------+-----------+------------
9223372036854775807 | NEW_BLOCK | 2147483647
(1 row)
Also, is it normal for the block_num just above to be -1?
Edited by Eric Frias