dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

support calling eval within multi/exec block

Open romange opened this issue 2 years ago • 2 comments

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:

  1. clone https://github.com/OptimalBits/bull/
  2. install the dependencies npm i
  3. run tests against local dragonfly ./dragonfly --default_lua_flags=allow-undeclared-keys --vmodule=main_service=2,reply_builder=1 --dbfilename="" using npm test
  4. Track dragonfly errors.

@dranikpg is my thinking correct?

romange avatar Jun 16 '23 07:06 romange

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

dranikpg avatar Jun 17 '23 15:06 dranikpg

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=...).

romange avatar Jun 17 '23 16:06 romange