wallet: print progress reports for large account migration.
What changed, and why it matters
This commit only adds progress messages (logging) during a database migration. It does not change how data is moved or stored, and it does not fix or introduce any security issue. It is purely a user-experience improvement so operators can see that a long upgrade is still running.
No security action needed. Treat as a normal logging/usability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds a helper give_progress() that returns true every 10 seconds and uses it inside two existing loops in migrate_from_account_db() to emit log_info() progress lines while inserting chain_events and channel_events. No logic, transaction handling, SQL, memory allocation, or access control is changed.
Changed components
wallet/account_migration.cInspect captured patch +21 / −0
diff --git a/wallet/account_migration.c b/wallet/account_migration.c
index 60e5bced..65e72e14 100644
--- a/wallet/account_migration.c
+++ b/wallet/account_migration.c
@@ -87,6 +87,17 @@ struct chain_event {
bool we_opened;
};
+/* Every 10 seconds, give progress indication */
+static bool give_progress(struct timemono *prev)
+{
+ struct timemono now = time_mono();
+ if (time_to_sec(timemono_between(now, *prev)) >= 10) {
+ *prev = now;
+ return true;
+ }
+ return false;
+}
+
static struct chain_event *stmt2chain_event(const tal_t *ctx, struct db_stmt *stmt)
{
struct chain_event *e = tal(ctx, struct chain_event);
@@ -354,6 +365,7 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
size_t descriptions_migrated = 0;
struct db_stmt *stmt;
int version;
+ struct timemono prev;
/* Initialize wait indices: we're going to use it to generate ids. */
load_indexes(db, ld->indexes);
@@ -379,6 +391,7 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
}
/* Load events */
+ prev = time_mono();
db_begin_transaction(account_db);
version = db_get_version(account_db);
/* -1 means empty database (Postgres usually). */
@@ -396,6 +409,8 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
db_commit_transaction(account_db);
tal_free(account_db);
+ log_debug(ld->log, "Transferring %zu chain_events",
+ tal_count(chain_events));
for (size_t i = 0; i < tal_count(chain_events); i++) {
const struct chain_event *ev = chain_events[i];
struct mvt_account_id *account = tal(ev, struct mvt_account_id);
@@ -486,8 +501,12 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
wallet_datastore_save_utxo_description(db, &ev->outpoint, ev->desc);
descriptions_migrated++;
}
+ if (give_progress(&prev))
+ log_info(ld->log, "Inserted %zu/%zu chain_events", i, tal_count(chain_events));
}
+ log_debug(ld->log, "Transferring %zu channel_events",
+ tal_count(channel_events));
for (size_t i = 0; i < tal_count(channel_events); i++) {
const struct channel_event *ev = channel_events[i];
struct mvt_account_id *account = tal(ev, struct mvt_account_id);
@@ -546,6 +565,8 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
wallet_datastore_save_payment_description(db, ev->payment_id, ev->desc);
descriptions_migrated++;
}
+ if (give_progress(&prev))
+ log_info(ld->log, "Inserted %zu/%zu channel_events", i, tal_count(channel_events));
}
log_info(ld->log, "bookkeeper migration complete: migrated %zu chainmoves, %zu channelmoves, %zu descriptions",
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.