Transactions MULTI/EXEC inside modules

6 views
Skip to first unread message

Simone Mosciatti

unread,
Jul 28, 2019, 8:26:13 AM7/28/19
to redis-module-devs
Hi all,

I am trying to execute a MULTI/EXEC transaction inside RediSQL.
Unfortunately it doesn't seems to work.

I use the RM_Call interface in this way:

```
RM_Call(context, "MULTI", "");
```
The initial MULTI works fine and it simply returns `OK`.

However if I then try to call the EXEC `RM_Call(context, "EXEC", "")` it reply with an error => `ERR EXEC without MULTI`

Why?

Moreover, if I try to execute commands between the MULTI and the EXEC the commands behave like they were not in a transaction, they don't return `QUEUED` but they simply return their result.

Is this expected?
Moreover, is necessary to wrap commands inside a transaction at all or Redis already wraps all the comands from a module in a transaction and execute the transaction only if the module command return successfully?

My use case is to push results of queries into a stream, however if we hit the timeout before I have finished to publish everything I would like to DISCARD the transaction, otherwise I want to execute it.
Is necessary to use MULTI/EXEC?

Cheers,
Simone

Itamar Haber

unread,
Jul 28, 2019, 8:50:51 AM7/28/19
to Simone Mosciatti, redis-module-devs
Hello Simone,

I may be wrong here, but MULTI/EXEC is meaningless inside a module's command. The command is blocking by nature, so delay the addition to the stream (or any writes for that matter) until the end of the code path and perform them according to the timeout or other conditions.

Cheers,

--
You received this message because you are subscribed to the Google Groups "redis-module-devs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-module-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-module-devs/2f326d21-717e-41e7-b4f7-53dd045b3d8c%40googlegroups.com.


--

Itamar Haber
Technicalist Evangely

Phone: +972.54.567.9692

Redis Labs

Reply all
Reply to author
Forward
0 new messages