Skip to content

lightningd question: Can we expect db_write's after a "shutdown" notification? #4785

Closed
@SimonVrouwe

Description

@SimonVrouwe

While working on the backup plugin here to use the "shutdown" notification for cleanup, a questions arose: Can there be db_write's after the "shutdown" notification?

The code below suggest it can:

/* Tell plugins we're shutting down. */
shutdown_plugins(ld);
shutdown_subdaemons(ld);
/* Clean up the JSON-RPC. This needs to happen in a DB transaction since
* it might actually be touching the DB in some destructors, e.g.,
* unreserving UTXOs (see #1737) */
db_begin_transaction(ld->wallet->db);
tal_free(ld->jsonrpc);
db_commit_transaction(ld->wallet->db);

The separate freeing of ld->jsonrpc inside a db transaction was added long time ago in PR #1755 for a particular case of un-reserving the utxos (in destructor destroy_utxos) of a fundchannel command that didn't return when the remote peer hanged.

But since v0.9.1 (PR #3867) that destructor (destroy_utxos) is not used anymore, AFAIU utxos are now unreserved by blockheight.

Are there other destructors hanging on ld->jsonrpc that do db transaction? If not, then PR #1755 can be reverted?

Maybe the documentation can be more explicit what plugins can expect, such as no rpc calls (e.g. datastore) after "shutdown".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions