Firstly, thanks for the bindings. I've been using them in production for quite a while without any serious issues, until now.
Digging a bit deeper and it looks like it may be an issue in the erlfdb_nif with a mutex not begin destroyed.
erlfdb_nif =>
#{binary => {72,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_mutex =>
{2240960,206493,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_tid => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
drv_binary => {107,1717,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
nif_internal => {0,0,0,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
#{binary => {162,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_mutex =>
{4634393,423889,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_tid => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
drv_binary => {257,4976,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
nif_internal => {0,0,0,89,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
I may be approaching this incorrectly, but I can replicate the increase in mutex counts just by performing transaction set operations and the mutex count does not ever decrease.
1> I = fun() -> {ok, {_,_,#{erlfdb_nif := N}}} = instrument:allocations(), N end.
#Fun<erl_eval.45.79398840>
2> Gen = fun(Size) when is_integer(Size), Size > 1 -> RandBin = crypto:strong_rand_bytes(Size - 1), <<"asdf", RandBin/binary>> end.
#Fun<erl_eval.44.79398840>
3> Db = erlfdb:open(<<"fdb.local.cluster">>).
{erlfdb_database,#Ref<0.698868889.2384330753.87336>}
4> I().
#{binary => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_mutex => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_tid => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
5> [begin V = Gen(X), K = integer_to_binary(X,32), ok = erlfdb:transactional(Db, fun(Tx) -> erlfdb:set(Tx, K, V) end) end || X <- lists:seq(10,10000)].
[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,
ok,ok,ok,ok,ok,ok,ok,ok,ok,ok|...]
6> I().
#{binary => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_mutex => {9989,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_tid => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
7> [begin V = Gen(X), K = integer_to_binary(X,32), ok = erlfdb:transactional(Db, fun(Tx) -> erlfdb:set(Tx, K, V) end) end || X <- lists:seq(10,10000)].
[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,
ok,ok,ok,ok,ok,ok,ok,ok,ok,ok|...]
8> I().
#{binary => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_mutex => {19980,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
driver_tid => {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}