db: Move tracking of pending statements into the struct db

We now have a much stronger consistency check from the combination of
transaction wrapping, tal memory leak detection. Tramsaction wrapping ensures
that each statement is executed before the transaction is committed. The
commit is also driven by the `io_loop`, which means that it is no longer
possible for us to have statements outside of transactions and transactions
are guaranteed to commit at the round's end.

By adding the tal-awareness we can also get a much better indication as to
whether we have un-freed statements flying around, which we can test at the
end of the round as well.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-08-28 14:56:19 +02:00
committed by Rusty Russell
parent b06cb68330
commit b6d583c26a
5 changed files with 25 additions and 66 deletions

View File

@@ -571,11 +571,7 @@ static void pidfile_create(const struct lightningd *ld)
* extra sanity checks, and it's also a good point to free the tmpctx. */
static int io_poll_lightningd(struct pollfd *fds, nfds_t nfds, int timeout)
{
/*~ In particular, we should *not* have left a database transaction
* open! */
db_assert_no_outstanding_statements();
/* The other checks and freeing tmpctx are common to all daemons. */
/* These checks and freeing tmpctx are common to all daemons. */
return daemon_poll(fds, nfds, timeout);
}

View File

@@ -45,9 +45,6 @@ void daemon_setup(const char *argv0 UNNEEDED,
/* Generated stub for daemon_shutdown */
void daemon_shutdown(void)
{ fprintf(stderr, "daemon_shutdown called!\n"); abort(); }
/* Generated stub for db_assert_no_outstanding_statements */
void db_assert_no_outstanding_statements(void)
{ fprintf(stderr, "db_assert_no_outstanding_statements called!\n"); abort(); }
/* Generated stub for db_begin_transaction_ */
void db_begin_transaction_(struct db *db UNNEEDED, const char *location UNNEEDED)
{ fprintf(stderr, "db_begin_transaction_ called!\n"); abort(); }