RedisGraph / RedisGraph

A graph database as a Redis module
https://redis.io/docs/stack/graph/
Other
2.01k stars 229 forks source link

RedsGraph stuck in "replicating" after DUMP and RESTORE used to copy graph #1626

Closed jonaskello closed 3 years ago

jonaskello commented 3 years ago

Each graph in RedisGraph is stored on a key. For keys we can use the DUMP and RESTORE commands in Redis to copy them. However when I do that RedisGraph gets stuck and only returns "replicating" messages to all further commands for any key.

Steps to reproduce

Run these commands in Redis CLI:

>> GRAPH.QUERY MotoGP "CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"
1) 1) "Labels added: 2"
   2) "Nodes created: 6"
   3) "Properties set: 6"
   4) "Relationships created: 3"
   5) "Cached execution: 0"
   6) "Query internal execution time: 9.217700 milliseconds"

>> eval "redis.call('RESTORE', KEYS[2], 0, redis.call('DUMP', KEYS[1]))" 2 MotoGP MotoGPCopy
(nil)

>> GRAPH.QUERY MotoGP "MATCH (a) RETURN a"
(error) RedisGraph module is currently replicating

I'm using a singe docker container locally on my computer with image redislabs/redisgraph:2.4.1. So no replication should be involved as far as I understand.

The DUMP/RESTORE approach works in image redislabs/redisgraph:2.0.20 but image redislabs/redisgraph:2.2.15 and above gives the (error) RedisGraph module is currently replicating error. So it seems this is a regression bug.

I previously reported this on #1076 but since this seems like a bug and that issue is a feature request I decided to open a separate issue for this bug.

jonaskello commented 3 years ago

As mentioned here, there is a known limitation that you can only use RESTORE to the same key as the data was DUMP:ed from. So you can use RENAME to make a copy like this:

>> GRAPH.QUERY MotoGP "CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"
1) 1) "Labels added: 2"
   2) "Nodes created: 6"
   3) "Properties set: 6"
   4) "Relationships created: 3"
   5) "Cached execution: 0"
   6) "Query internal execution time: 1.053900 milliseconds"

>> eval "local o = redis.call('DUMP', KEYS[1]);redis.call('RENAME', KEYS[1], KEYS[2]);redis.call('RESTORE', KEYS[1], 0, o)" 2 MotoGP MotoGPCopy
(nil)

>> GRAPH.QUERY MotoGPCopy "MATCH (a) RETURN a"
1) 1) "a"
2) 1) 1) 1) 1) "id"
            2) (integer) 0
         2) 1) "labels"
            2) 1) "Rider"

>> GRAPH.QUERY MotoGP "MATCH (a) RETURN a"
1) 1) "a"
2) 1) 1) 1) 1) "id"
            2) (integer) 0
         2) 1) "labels"
            2) 1) "Rider"