dragonfly
dragonfly copied to clipboard
support calling eval within multi/exec block
Usually we do not support muti/exec with eval inside. However, bull framework has a specific transaction
HMSET ...
EVAL ....
that runs both operations together. Now, specifically for bull we must run dragonfly with --default_lua_flags=allow-undeclared-keys, therefore, EVAL runs as a global transaction. Therefore, we can relatively easy support this combination, and if there is EVAL call that runs a script with allow-undeclared-keys property, make the parent MULTI transaction global as well and be able to support a mixture of EVAL and other calls.
To reproduce:
- clone https://github.com/OptimalBits/bull/
- install the dependencies
npm i - run tests against local dragonfly
./dragonfly --default_lua_flags=allow-undeclared-keys --vmodule=main_service=2,reply_builder=1 --dbfilename=""usingnpm test - Track dragonfly errors.
@dranikpg is my thinking correct?
Yes, that's theoretically possible.
I only see the following issue: if really EVAL is used, then the script flags could be set within the script itself (i.e. with #!lua flags=.... or by SHA, which needs to be computed explicitly. In that case it would require a little extra work to detect it ahead whether any script is global.
A side question. Why can't HMSET be part of EVAL? I understand its not that elegant and breaks the 'single responsibility' principle, but it works
What do you mean why? It's not in our control, is not it?
Any solution that requires library-side changes is undesirable, so the goal is to adjust transparently (except running with --default_lua_flags=...).