Wait for massive sync before calling next iteration

In the case SIGINT is delivered to hivemind process at the right moment at the end of massive sync, it gets stuck. This is because of a Postgres lock on hivemind_app.accounts_view. Accounts indexer tries to acquire AccessShareLock to insert a new account, but AccessExclusiveLock is already acquired by main sync loop. This is because the end of current range is reached, which tries to recreate accounts_view via the call chain:

self._query_for_app_next_block -> hive.app_next_iteration -> hive.app_context_attach -> hive.create_accounts_view -> CREATE OR REPLACE VIEW %s.accounts_view which takes an exclusive lock, which blocks INSERT INTO hivemind_app.hive_accounts.

The solution is to wait for massive block consumption to complete before starting next iteration.

Fixes #300 (closed)

Merge request reports

Loading