RedBeardLab / rediSQL

Redis module that provides a completely functional SQL database

Home Page:https://redisql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redisql not support transaction?

xiao321 opened this issue · comments

redis shutdown because of the transaction.

my code:
Transaction transaction = jedis.multi();
transaction.executeSQL("test", "select * from op_driver");
transaction.executeSQL("test", "select count(*) from op_driver");
List exec = transaction.exec();
transaction.close();

my client error:
redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:202)
at redis.clients.jedis.util.RedisInputStream.readByte(RedisInputStream.java:43)
at redis.clients.jedis.Protocol.process(Protocol.java:154)
at redis.clients.jedis.Protocol.read(Protocol.java:219)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:313)
at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:280)
at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:284)
at redis.clients.jedis.Jedis.executeSQL(Jedis.java:3661)

redisql server log:
[2019-07-05T09:26:57Z DEBUG redisql_lib::redis] Loop iteration
[2019-07-05T09:26:57Z DEBUG redis_sql::commands] Exec | GotDB
[2019-07-05T09:26:57Z DEBUG redis_sql::commands] Exec | BlockedClient
[2019-07-05T09:26:57Z DEBUG redis_sql::commands] Exec | Create Command
[2019-07-05T09:26:57Z DEBUG redis_sql::commands] Exec | GotDB
[2019-07-05T09:26:57Z DEBUG redis_sql::commands] Exec | BlockedClient
[2019-07-05T09:26:57Z DEBUG redis_sql::commands] Exec | Create Command
[2019-07-05T09:26:57Z DEBUG redisql_lib::redis] Exec | Query = "select * from op_driver"
Segmentation fault (core dumped)

What version are you using ? (of both redis and redisql).

How big are those tables?

I just tested and it worked without much of a fuss.

127.0.0.1:6379> multi
OK
127.0.0.1:6379> REDISQL.exec DB 'insert into foo values(3,4);'
QUEUED
127.0.0.1:6379> REDISQL.exec DB 'insert into foo values(4,5);'
QUEUED
127.0.0.1:6379> exec
1) (error) ERR Blocking module command called from transaction
2) (error) ERR Blocking module command called from transaction
127.0.0.1:6379> 
127.0.0.1:6379> multi
OK
127.0.0.1:6379> REDISQL.exec.now DB 'insert into foo values(4,5);'
QUEUED
127.0.0.1:6379> REDISQL.exec.now DB 'insert into foo values(3,4);'
QUEUED
127.0.0.1:6379> 
127.0.0.1:6379> exec
1) 1) DONE
   2) (integer) 1
2) 1) DONE
   2) (integer) 1
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> multi
OK
127.0.0.1:6379> REDISQL.exec.now DB 'select * from foo;'
QUEUED
127.0.0.1:6379> REDISQL.exec.now DB 'select count(*) from foo;'
QUEUED
127.0.0.1:6379> exec
1) 1) 1) (integer) 1
      2) (integer) 2
   2) 1) (integer) 3
      2) (integer) 4
   3) 1) (integer) 4
      2) (integer) 5
   4) 1) (integer) 4
      2) (integer) 5
   5) 1) (integer) 3
      2) (integer) 4
2) 1) 1) (integer) 5
127.0.0.1:6379> 

Please also note that blocking command seems to don't be supported during a redis transaction.

Also keep in mind that RediSQL has its own SQLite-backed transactions, if that may help your use case.

(REDISQL.EXEC is a blocking command, while REDISQL.EXEC.NOW is not blocking, same semantic for the statements commands.)

test env :
redis 5.05
v1.0.3-rc02 libredis_sql_debug.so

test record:

localhost:7380> multi
OK
localhost:7380> redisql.exec test "select * from a"
QUEUED
localhost:7380> redisql.exec test "select count(*) from a"
QUEUED
localhost:7380> exec
1) (error) ERR Blocking module command called from transaction
2) (error) ERR Blocking module command called from transaction
localhost:7380> multi
Could not connect to Redis at localhost:7380: Connection refused
not connected> 

the redis shutdown

It should definitely not shutdown!

I was indeed on redis 5.0.3 so something must have changed.

Please keep in mind that REDISQL.EXEC is never going to work inside transactions and you should use REDISQL.EXEC.NOW!

Let me investigate and many thanks for the report!

yes , you are right. i test it. the redis 5.0.3 is ok with redisql 1.0.3 .
i will change the redis version.