RedisLabsModules / redismodule-rs

Rust API for Redis Modules API
BSD 3-Clause "New" or "Revised" License
269 stars 65 forks source link

Improve thread safe context and locks managment #55

Open gkorland opened 5 years ago

gavrie commented 4 years ago

@gkorland please explain what you want to do in this ticket.

let4be commented 3 years ago

I'm currently trying to write a redis module using threads and redis is crashing as soon as I'm starting to execute command in ThreadSafeContext

=== REDIS BUG REPORT START: Cut & paste starting from here ===
1:M 24 Jun 2021 21:34:38.373 # === ASSERTION FAILED ===
1:M 24 Jun 2021 21:34:38.373 # ==> module.c:4192 '(c->flags & CLIENT_BLOCKED) == 0' is not true
...

any idea what's up?

let4be commented 3 years ago

If I do exactly as in example ctx.call("INCR", &["threads"]).unwrap(); it works

but as soon as I'm trying to use Deref 'ed redis_module::Context in a regular ctx.call(... all hell breaks lose and it crashes

edit: probably doesn't have to do anything with Deref nor with ThreadSafeContext... regular commands work, but I'm trying to read data returned by RedisGraph module(from my own module)... and it crashes on command execution

narrowed down to ctx.call("GRAPH.QUERY", &["domains", "CALL algo.pageRank('domain', 'links') YIELD node, score RETURN node.name, score ORDER BY score DESC LIMIT 1000"]) kills the server... no Result, nothing :\

edit: calling this command right from init leads to the same result - crash

edit: callingctx.call("GRAPH.QUERY", &["domains", ""]) crashes the server calling ctx.call("GRAPH.QUERY", &["domains"]) does not (right in the beginning of init, no unwrap or anything just call with result discard)

let4be commented 3 years ago

Probably has to do with the way RedisGraph returns the data There's a lot of complicated nested arrays

127.0.0.1:6379> graph.QUERY domains "CREATE (facebook:domain {name: 'facebook.com'}),(habr:domain {name: 'habr.com'}),(bash:domain {name: 'bash.im'}),(habr)-[:links]->(facebook),(bash)-[:links]->(facebook)"
1) 1) "Labels added: 1"
   2) "Nodes created: 3"
   3) "Properties set: 3"
   4) "Relationships created: 2"
   5) "Cached execution: 0"
   6) "Query internal execution time: 3.933168 milliseconds"
127.0.0.1:6379> GRAPH.QUERY domains "CALL algo.pageRank('domain', 'links') YIELD node, score RETURN node.name, score ORDER BY score DESC LIMIT 1000"
1) 1) "node.name"
   2) "score"
2) 1) 1) "facebook.com"
      2) "0.735017001628876"
   2) 1) "habr.com"
      2) "0.132491484284401"
   3) 1) "bash.im"
      2) "0.132491484284401"
3) 1) "Cached execution: 0"
   2) "Query internal execution time: 6.270944 milliseconds"

any advice on where to dig?

although even ctx.call("GRAPH.QUERY", &["wtf", "asdasdasdasd"]) crashes it... I'm confused :\

gavrie commented 3 years ago

@let4be thanks for reporting the issue -- though it would have been better to create a new issue instead of commenting on the existing one. @gkorland any ideas here?