KVS: Actually fix the memory leaks
What
This MR is based on !15148 (merged) (the first two commits) and !15146 (merged) (the first three commits). It actually fixes the memory leaks from the KVS.
Why
We want to fix the memory leaks from the KVS.
How
We change the fix introduced !15076 (merged) to ensure the opened files table actually do not leak. For the last_actions table, we just clean up the table when at the end of an action, the file does not exist anymore.
Manually testing the MR
dune exec src/lib_stdlib_unix/test/main.exe -- kvs -v
Last commit is temporary, but allows you to run the test in a loop (another way to do it is via --loop. UX is poor, but you can check by removing one of the fix, it will fail relatively quickly.
Another way to observe it is by observing the metrics on tezt-cloud. A running experiment on this branch can accessed here: http://dbg-bp.nl-dal.saroupille.com/ . You can check the two metrics associated with the kvs and they are at 0.
You can also check it yourself by running:
dune exec tezt/tests/cloud/main.exe -- cloud dal -v --log-file /tmp/log --network ghostnet --bootstrap --prometheus --localhost