Skip to content

Make initial root migration for converting ledgers gradual #17875

@cjjdespres

Description

@cjjdespres

Related to #17874 and #17570.

I realized that the initial ledger migration in the converting merkle tree is written with one set_batch_accounts on all the accounts in the ledger:

let of_ledgers_with_migration primary_ledger converting_ledger =
assert (Converting_ledger.num_accounts converting_ledger = 0) ;
let accounts =
Primary_ledger.foldi primary_ledger ~init:[] ~f:(fun addr acc account ->
(addr, convert account) :: acc )
in
Converting_ledger.set_batch_accounts converting_ledger accounts ;
{ primary_ledger; converting_ledger }

This is going to cause the daemon to become unresponsive for that entire operation, as it will have to rehash all the accounts and recreate the auxiliary tables in the database in a single async job. This could cause networking bugs like the one fixed in #17874; at the very least it will result in a poor user experience if the daemon randomly becomes unresponsive to commands.

We can likely fix this simply by having a new ledger interface method like set_batch_accounts that returns a unit Deferred.t, and which would do its various operations in chunks, giving the scheduler the opportunity to run other async jobs (like handling networking).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions