RedBeardLab / rediSQL

Redis module that provides a completely functional SQL database
https://redisql.com
Other
1.55k stars 150 forks source link

Insert data into a table crashed redis #85

Closed ghost closed 4 years ago

ghost commented 5 years ago

Also reported in the redis project but it is related to inserting data into redis using rediSQL.

I have a redis-server instance running on a raspberry PI 4 with 2Gb of memory. REDIS was running normally until I started using it today by creating a rediSQL DB, create a table then attempting to put data into this table.

At the attempt to insert data, I got an "Error: Connection reset by peer" which is when redis crashed. This is my console:

127.0.0.1:6379> REDISQL.CREATE_DB DB OK 127.0.0.1:6379> REDISQL.EXEC DB "CREATE TABLE ttyRoute( column1 CHAR(2), column1 CHAR(3), column3 CHAR(2), column4 VARCHAR(5), column5 CHAR(4), column6 CHAR(4), options TEXT)"

DONE (integer) 0 127.0.0.1:6379> REDISQL.EXEC DB "INSERT INTO ttyRoute VALUES(('XX', 'YYY', 'ZZ',,, 'QUE1');" Error: Connection reset by peer (3.23s) Redis error log:

=== REDIS BUG REPORT START: Cut & paste starting from here === 28498:M 24 Aug 2019 17:55:55.140 # Redis 5.0.3 crashed by signal: 11 28498:M 24 Aug 2019 17:55:55.140 # Crashed running the instruction at: 0xb6f6ef50 28498:M 24 Aug 2019 17:55:55.140 # Accessing address: 0x16 28498:M 24 Aug 2019 17:55:55.140 # Failed assertion: (:0)

------ STACK TRACE ------ EIP: /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so(+0x1f50)[0xb6f6ef50]

Backtrace: /usr/bin/redis-server 127.0.0.1:6379(logStackTrace+0x3c)[0x7ad30] /usr/bin/redis-server 127.0.0.1:6379(sigsegvHandler+0x8c)[0x7b478] /lib/arm-linux-gnueabihf/libc.so.6(__default_rt_sa_restorer+0x0)[0xb6c24130]

------ INFO OUTPUT ------

Server

redis_version:5.0.3 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:afa0decbb6de285f redis_mode:standalone os:Linux 4.19.58-v7l+ armv7l arch_bits:32 multiplexing_api:epoll atomicvar_api:atomic-builtin gcc_version:8.3.0 process_id:28498 run_id:504ec3a7990435a686fba198748ec677e20732cc tcp_port:6379 uptime_in_seconds:525000 uptime_in_days:6 hz:10 configured_hz:10 lru_clock:6352267 executable:/usr/bin/redis-server config_file:/etc/redis/redis.conf

Clients

connected_clients:1 client_recent_max_input_buffer:2 client_recent_max_output_buffer:0 blocked_clients:1

Memory

used_memory:384752 used_memory_human:375.73K used_memory_rss:13422592 used_memory_rss_human:12.80M used_memory_peak:384752 used_memory_peak_human:375.73K used_memory_peak_perc:106.03% used_memory_overhead:341554 used_memory_startup:291928 used_memory_dataset:43198 used_memory_dataset_perc:46.54% allocator_allocated:4176480 allocator_active:23199744 allocator_resident:35258368 total_system_memory:2033692672 total_system_memory_human:1.89G 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:50000000 maxmemory_human:47.68M maxmemory_policy:allkeys-lru allocator_frag_ratio:5.55 allocator_frag_bytes:19023264 allocator_rss_ratio:1.52 allocator_rss_bytes:12058624 rss_overhead_ratio:0.38 rss_overhead_bytes:-21835776 mem_fragmentation_ratio:41.69 mem_fragmentation_bytes:13100656 mem_not_counted_for_evict:0 mem_replication_backlog:0 mem_clients_slaves:0 mem_clients_normal:49574 mem_aof_buffer:0 mem_allocator:jemalloc-5.1.0 active_defrag_running:0 lazyfree_pending_objects:0

Persistence

loading:0 rdb_changes_since_last_save:2 rdb_bgsave_in_progress:0 rdb_last_save_time:1566633010 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:0 rdb_current_bgsave_time_sec:-1 rdb_last_cow_size:1007616 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

Stats

total_connections_received:1 total_commands_processed:4 instantaneous_ops_per_sec:0 total_net_input_bytes:317 total_net_output_bytes:14098 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 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:4675 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

Replication

role:master connected_slaves:0 master_replid:af124dcc86ece7c3db0922e737c42e808602e831 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:742.290099 used_cpu_user:1431.282625 used_cpu_sys_children:0.000000 used_cpu_user_children:0.012795

Commandstats

cmdstat_REDISQL.CREATE_DB:calls=1,usec=29226,usec_per_call=29226.00 cmdstat_REDISQL.EXEC:calls=2,usec=325,usec_per_call=162.50 cmdstat_command:calls=1,usec=7570,usec_per_call=7570.00

Cluster

cluster_enabled:0

Keyspace

db0:keys=1,expires=0,avg_ttl=0

------ CLIENT LIST OUTPUT ------ id=3 addr=127.0.0.1:55764 fd=8 name= age=439 idle=0 flags=b db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=REDISQL.EXEC

------ REGISTERS ------

------ FAST MEMORY TEST ------ 28498:M 24 Aug 2019 17:55:55.151 # Bio thread for job type #0 terminated 28498:M 24 Aug 2019 17:55:55.152 # Bio thread for job type #1 terminated 28498:M 24 Aug 2019 17:55:55.152 # Bio thread for job type #2 terminated Preparing to test memory region ed000 (49152 bytes) Preparing to test memory region b0ee0000 (4390912 bytes) Preparing to test memory region b1330000 (393216 bytes) Preparing to test memory region b13a0000 (65536 bytes) Preparing to test memory region b13f0000 (917504 bytes) Preparing to test memory region b14f0000 (2424832 bytes) Preparing to test memory region b1750000 (196608 bytes) Preparing to test memory region b17a0000 (327680 bytes) Preparing to test memory region b1800000 (655360 bytes) Preparing to test memory region b18de000 (8192 bytes) Preparing to test memory region b18e0000 (327680 bytes) Preparing to test memory region b1950000 (196608 bytes) Preparing to test memory region b19aa000 (24576 bytes) Preparing to test memory region b19b0000 (262144 bytes) Preparing to test memory region b19f0000 (6422528 bytes) Preparing to test memory region b2010000 (1966080 bytes) Preparing to test memory region b2200000 (2097152 bytes) Preparing to test memory region b2400000 (2162688 bytes) Preparing to test memory region b2610000 (1507328 bytes) Preparing to test memory region b2780000 (262144 bytes) Preparing to test memory region b27ce000 (2097152 bytes) Preparing to test memory region b29cf000 (2097152 bytes) Preparing to test memory region b2bd0000 (2097152 bytes) Preparing to test memory region b2dd0000 (1048576 bytes) Preparing to test memory region b2f10000 (458752 bytes) Preparing to test memory region b2fb0000 (983040 bytes) Preparing to test memory region b30d0000 (655360 bytes) Preparing to test memory region b3190000 (196608 bytes) Preparing to test memory region b3200000 (983040 bytes) Preparing to test memory region b3310000 (655360 bytes) Preparing to test memory region b33d0000 (196608 bytes) Preparing to test memory region b3420000 (1245184 bytes) Preparing to test memory region b3560000 (3211264 bytes) Preparing to test memory region b3880000 (2097152 bytes) Preparing to test memory region b3a80000 (5767168 bytes) Preparing to test memory region b4005000 (2097152 bytes) Preparing to test memory region b47bf000 (16384 bytes) Preparing to test memory region b47ee000 (8388608 bytes) Preparing to test memory region b4fef000 (8388608 bytes) Preparing to test memory region b57f0000 (8388608 bytes) Preparing to test memory region b5ff0000 (131072 bytes) Preparing to test memory region b6010000 (10616832 bytes) Preparing to test memory region b6a30000 (524288 bytes) Preparing to test memory region b6bf5000 (8192 bytes) Preparing to test memory region b6d42000 (12288 bytes) Preparing to test memory region b6d6d000 (8192 bytes) Preparing to test memory region b6eca000 (40960 bytes) Preparing to test memory region b6f45000 (4096 bytes) Preparing to test memory region b6f6b000 (8192 bytes) Preparing to test memory region b6fa3000 (8192 bytes) *** Preparing to test memory region b6fab000 (28672 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.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.

------ DUMPING CODE AROUND EIP ------ Symbol: (null) (base: (nil)) Module: /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (base 0xb6f6d000) $ xxd -r -p /tmp/dump.hex /tmp/dump.bin $ objdump --adjust-vma=(nil) -D -b binary -m i386:x86-64 /tmp/dump.bin

=== REDIS BUG REPORT END. Make sure to include from START to END. ===

Let me know if you need anything else.

Ron

siscia commented 5 years ago

Hi Ron,

Thanks for the report!

You are using it correctly, so I am not sure what is the underneath issue.

I see an extra parenthesis in your insert statement, it should not cause this issue anyway.

Other statement works as expected?

I don't have a RPI myself, I will try to reproduce on some cloud provider that offer ARM.

You used the correct build of RediSQL, which I believe being ARMv7, can you confirm?

Also, simple query like: "SELECT 1;" do they work?

What version of RediSQL are you using?

ghost commented 5 years ago

Hi Simone,

Indeed I use the ARMv7 version of both Redis and RediSQL

The create DB command worked correctly, the create table worked as well. It failed on the insert. I attached the console to the report in github.

Thanks for looking into this.

Regards Ron

From: Simone Mosciatti

Date: Saturday, 24 August 2019 at 8:55 pm

Subject: Re: [RedBeardLab/rediSQL] Insert data into a table crashed redis (#85)

Hi Ron,

Thanks for the report!

You are using it correctly, so I am not sure what is the underneath issue.

I see an extra parenthesis in your insert statement, it should not cause this issue anyway.

Other statement works as expected?

I don't have a RPI myself, I will try to reproduce on some cloud provider that offer ARM.

You used the correct build of RediSQL, which I believe being ARMv7, can you confirm?

Also, simple query like: "SELECT 1;" do they work?

What version of RediSQL are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/RedBeardLab/rediSQL/issues/85?email_source=notifications&email_token=AM7R73CSCGKW35L3NYXQSYDQGEHTLA5CNFSM4IPF2KAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5B52GQ#issuecomment-524541210, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AM7R73CAGDI57654I3JA2DDQGEHTLANCNFSM4IPF2KAA.

ghost commented 5 years ago

A simple select as above works, although there is no data in the DB: 127.0.0.1:6379> REDISQL.EXEC SELECT 1 (error) ERR - Error the key is empty 127.0.0.1:6379> REDISQL.EXEC DB "CREATE TABLE TEST( A TEXT, B CHAR)" 1) DONE 2) (integer) 0 127.0.0.1:6379> REDISQL.EXEC DB "SELECT A,B FROM TEST" 1) DONE 2) (integer) 0 127.0.0.1:6379> REDISQL.EXEC DB "INSERT INTO TEST VALUES('coffee', 'arabica')" Could not connect to Redis at 127.0.0.1:6379: Connection refused (3.64s) not connected>

Crashed again on the insert, I guess it is at least consistent. The version of RediSQL I am using is: pi@raspberrypi:/etc/redis $ ls redis.conf redisql.so redisql_v1.0.2_ARMv7.so rejson.so pi@raspberrypi:/etc/redis $

Regards Ron

siscia commented 5 years ago

Didn't forget about you.

But is a little more complex reproducing the issue. How urgent it is? Can you run/develop on x86_64?

ghost commented 5 years ago

Not that urgent, I am using MySQL/MariaDB in the mean time as the software should be identical irrespective of the DB used.