canonical / dqlite

Embeddable, replicated and fault-tolerant SQL engine.
https://dqlite.io
Other
3.8k stars 215 forks source link

Raft uv_timer leak when creating and destroying node #504

Open MathieuBordere opened 1 year ago

MathieuBordere commented 1 year ago

src/server.c:176: dqlite__close: Assertion 'rv == 0' failed.

Reported by @stgraber, see failures here https://jenkins.linuxcontainers.org/job/lxd-github-commit/4903/

It's related to a TODO . This timer is not properly closed when only calling dqlite_node_create and dqlite_node_destroy without starting and stopping the node. This sequence of calls is hit in the node recovery logic, where we explicitly don't want to run the node and made visible by the newly introduced assert in this change that asserts the rv of uv_loop_close.

I will remove the newly introduced assert to fix the LXD test suite and track the proper fix in this issue.

MathieuBordere commented 1 year ago

Additionally, the sequence dqlite_node_create, dqlite_node_set_bind_address, dqlite_node_destroy will lead to triggering the assertion because the listener handle here https://github.com/canonical/dqlite/blob/c3ac4d8ad19f7057a5723a0e4b8d17d1d59fb079/src/server.c#L247 is still active.