RedisLabsModules / redismodule-rs

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

fail to call RedisGraph module #173

Open hcyrs opened 3 years ago

hcyrs commented 3 years ago

when i call RedisGraph in redismodule-rs, redis fail.

fn hello_person(ctx: &Context, _: Vec<RedisString>) -> RedisResult {
    let r = ctx.call("GRAPH.QUERY", &["person", r#"MATCH (n) RETURN n"#]);
    match r {
        Ok(v) => {
            ctx.log_notice(&format!("{:?}", v));
        }
        Err(e) => {
            ctx.log_warning(&format!("{:?}", e));
        }
    }
    return Ok("OK".into());
}

Result:

$ redis-cli
127.0.0.1:6379> hello.person
Could not connect to Redis at 127.0.0.1:6379: Connection refused
(0.68s)
not connected>

Version:

redis-module: v0.21

Redis server: v6.2.4

RedisGraph: master

gavrie commented 3 years ago

Looks like a crash. Could you provide the Redis logs please?

hcyrs commented 3 years ago

HERE is the log info.

=== REDIS BUG REPORT START: Cut & paste starting from here ===
1687402:M 21 Jul 2021 18:19:12.545 # === ASSERTION FAILED ===
1687402:M 21 Jul 2021 18:19:12.545 # ==> module.c:4192 '(c->flags & CLIENT_BLOCKED) == 0' is not true

------ STACK TRACE ------

Backtrace:
/usr/local/bin/redis-server 127.0.0.1:6379(+0xddea9)[0x56162f6b4ea9]
/usr/local/lib/mymod/my_mod.so(+0xbdae)[0x7f651be11dae]
/usr/local/lib/mymod/my_mod.so(+0x9b41)[0x7f651be0fb41]
/usr/local/bin/redis-server 127.0.0.1:6379(RedisModuleCommandDispatcher+0x67)[0x56162f6b20c7]
/usr/local/bin/redis-server 127.0.0.1:6379(call+0x96)[0x56162f6250b6]
/usr/local/bin/redis-server 127.0.0.1:6379(processCommand+0x5d3)[0x56162f626ca3]
/usr/local/bin/redis-server 127.0.0.1:6379(processCommandAndResetClient+0x20)[0x56162f63a090]
/usr/local/bin/redis-server 127.0.0.1:6379(processInputBuffer+0xea)[0x56162f63c90a]
/usr/local/bin/redis-server 127.0.0.1:6379(+0xfcf5c)[0x56162f6d3f5c]
/usr/local/bin/redis-server 127.0.0.1:6379(aeProcessEvents+0x2ca)[0x56162f61d79a]
/usr/local/bin/redis-server 127.0.0.1:6379(aeMain+0x1d)[0x56162f61da2d]
/usr/local/bin/redis-server 127.0.0.1:6379(main+0x32a)[0x56162f619eaa]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f651beef0b3]
/usr/local/bin/redis-server 127.0.0.1:6379(_start+0x2e)[0x56162f61a3ae]

------ INFO OUTPUT ------
# Server
redis_version:6.2.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:38992ce41b13436a
redis_mode:standalone
os:Linux 5.4.0-77-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:9.3.0
process_id:1687402
process_supervised:no
run_id:9205df4d5699a4ddb42863bf29e31f8f8b74783b
tcp_port:6379
server_time_usec:1626862752545011
uptime_in_seconds:86
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:16250016
executable:/usr/local/bin/redis-server
config_file:/etc/redis/redis.conf
io_threads_active:0

# Clients
connected_clients:1
cluster_connections:0
maxclients:10000
client_recent_max_input_buffer:16
client_recent_max_output_buffer:0
blocked_clients:1
tracking_clients:0
clients_in_timeout_table:0

# Memory
used_memory:7098200
used_memory_human:6.77M
used_memory_rss:15253504
used_memory_rss_human:14.55M
used_memory_peak:7099056
used_memory_peak_human:6.77M
used_memory_peak_perc:99.99%
used_memory_overhead:902528
used_memory_startup:881616
used_memory_dataset:6195672
used_memory_dataset_perc:99.66%
allocator_allocated:7305184
allocator_active:7749632
allocator_resident:10604544
total_system_memory:33374715904
total_system_memory_human:31.08G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.06
allocator_frag_bytes:444448
allocator_rss_ratio:1.37
allocator_rss_bytes:2854912
rss_overhead_ratio:1.44
rss_overhead_bytes:4648960
mem_fragmentation_ratio:2.17
mem_fragmentation_bytes:8220600
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:20496
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0

# Persistence
loading:0
current_cow_size:0
current_cow_size_age:0
current_fork_perc:0.00
current_save_keys_processed:0
current_save_keys_total:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1626862666
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0

# Stats
total_connections_received:1
total_commands_processed:4
instantaneous_ops_per_sec:0
total_net_input_bytes:61
total_net_output_bytes:22583
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:1
evicted_keys:0
keyspace_hits:2
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
total_forks:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_error_replies:0
dump_payload_sanitizations:0
total_reads_processed:3
total_writes_processed:2
io_threaded_reads_processed:0
io_threaded_writes_processed:0

# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:3470830b2cfd2ff4a45a8ea34bda98cfe333f462
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.051257
used_cpu_user:0.093074
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
used_cpu_sys_main_thread:0.048303
used_cpu_user_main_thread:0.092216

# Modules
module:name=hello,ver=1,api=1,filters=0,usedby=[],using=[],options=[]
module:name=ReJSON,ver=999999,api=1,filters=0,usedby=[],using=[],options=[]
module:name=graph,ver=999999,api=1,filters=0,usedby=[],using=[],options=[]

# Commandstats
cmdstat_json.get:calls=1,usec=45,usec_per_call=45.00,rejected_calls=0,failed_calls=0
cmdstat_command:calls=1,usec=1044,usec_per_call=1044.00,rejected_calls=0,failed_calls=0
cmdstat_hello.json:calls=1,usec=173,usec_per_call=173.00,rejected_calls=0,failed_calls=0
cmdstat_graph.QUERY:calls=1,usec=23,usec_per_call=23.00,rejected_calls=0,failed_calls=0

# Errorstats

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=8,expires=0,avg_ttl=0

------ CLIENT LIST OUTPUT ------
id=9 addr=127.0.0.1:50210 laddr=127.0.0.1:6379 fd=8 name= age=20 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=23 qbuf-free=40931 argv-mem=12 obl=0 oll=0 omem=0 tot-mem=61460 events=r cmd=hello.person user=default redir=-1

------ CURRENT CLIENT INFO ------
id=9 addr=127.0.0.1:50210 laddr=127.0.0.1:6379 fd=8 name= age=20 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=23 qbuf-free=40931 argv-mem=12 obl=0 oll=0 omem=0 tot-mem=61460 events=r cmd=hello.person user=default redir=-1
argv[0]: 'hello.person'

------ MODULES INFO OUTPUT ------
# graph_executing commands

------ FAST MEMORY TEST ------
1687402:M 21 Jul 2021 18:19:12.545 # Bio thread for job type #0 terminated
1687402:M 21 Jul 2021 18:19:12.546 # Bio thread for job type #1 terminated
1687402:M 21 Jul 2021 18:19:12.546 # Bio thread for job type #2 terminated
*** Preparing to test memory region 56162f7e7000 (2277376 bytes)
*** Preparing to test memory region 561630cd4000 (135168 bytes)
*** Preparing to test memory region 7f64fc000000 (2125824 bytes)
*** Preparing to test memory region 7f6504000000 (135168 bytes)
*** Preparing to test memory region 7f650b800000 (8388608 bytes)
*** Preparing to test memory region 7f650c000000 (135168 bytes)
*** Preparing to test memory region 7f6510000000 (4194304 bytes)
*** Preparing to test memory region 7f6510600000 (8388608 bytes)
*** Preparing to test memory region 7f6510e00000 (4194304 bytes)
*** Preparing to test memory region 7f6511244000 (9437184 bytes)
*** Preparing to test memory region 7f6511b45000 (8388608 bytes)
*** Preparing to test memory region 7f6512346000 (8388608 bytes)
*** Preparing to test memory region 7f6512b47000 (8388608 bytes)
*** Preparing to test memory region 7f6513348000 (8388608 bytes)
*** Preparing to test memory region 7f6513c45000 (8388608 bytes)
*** Preparing to test memory region 7f6514446000 (8388608 bytes)
*** Preparing to test memory region 7f6514c47000 (8388608 bytes)
*** Preparing to test memory region 7f6515448000 (8388608 bytes)
*** Preparing to test memory region 7f6515c49000 (8388608 bytes)
*** Preparing to test memory region 7f651644a000 (8388608 bytes)
*** Preparing to test memory region 7f6516c4b000 (8388608 bytes)
*** Preparing to test memory region 7f651744c000 (8388608 bytes)
*** Preparing to test memory region 7f6517c4d000 (8388608 bytes)
*** Preparing to test memory region 7f651844e000 (8388608 bytes)
*** Preparing to test memory region 7f6518c4f000 (8388608 bytes)
*** Preparing to test memory region 7f6519450000 (8388608 bytes)
*** Preparing to test memory region 7f651b014000 (12288 bytes)
*** Preparing to test memory region 7f651b600000 (8388608 bytes)
*** Preparing to test memory region 7f651bec2000 (24576 bytes)
*** Preparing to test memory region 7f651c0b6000 (16384 bytes)
*** Preparing to test memory region 7f651c0d9000 (16384 bytes)
*** Preparing to test memory region 7f651c232000 (8192 bytes)
*** Preparing to test memory region 7f651c27a000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.

=== REDIS BUG REPORT END. Make sure to include from START to END. ===
gkorland commented 3 years ago

RedisGraph can't be called from another module since its command are not synchronous and run in parallel threads.