questdb / questdb

QuestDB is an open source time-series database for fast ingest and SQL queries
https://questdb.io
Apache License 2.0
14.54k stars 1.18k forks source link

SIGSEGV when running JIT filter #4338

Open matyasberry opened 7 months ago

matyasberry commented 7 months ago

To reproduce

running QuestDB in embedded mode, and running a query as follows:

WITH T1 as (SELECT instrument,o,h,l,c,v,qv,trck,tradingDate,timestamp FROM candles1M WHERE trck>0 AND  projectId='1' AND instrument='14IEBwbHGmiCH7c' AND timestamp<'1970-01-01T00:03:01Z' ORDER BY timestamp ASC)  SELECT * FROM T1 WHERE timestamp>='1970-01-01T00:01:00Z' UNION (SELECT * FROM T1 LIMIT -1)

results in a crash:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000000000a466, pid=7, tid=59
#
# JRE version: OpenJDK Runtime Environment (17.0.8+7) (build 17.0.8+7-alpine-r0)
# Java VM: OpenJDK 64-Bit Server VM (17.0.8+7-alpine-r0, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libquestdb14427631715435434242.so+0x4a5e3]  asmjit::String::_opVFormat(unsigned int, char const*, __va_list_tag*)+0x113
#

this is inside a docker image, based on alpine 3.19.1

OS config:

 # ulimit -Sn
1048576
# ulimit -Hn
1048576
# cat /proc/sys/vm/max_map_count
524288

QuestDB version:

7.3.10

OS, in case of Docker specify Docker and the Host OS:

ALPINE 3.19.1

File System, in case of Docker specify Host File System:

AWS t3.medium with AMAZON LINUX 2, amd64

Full Name:

Matyas

Affiliation:

Exberry

Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?

Additional context

No response

puzpuzpuz commented 7 months ago

There should be a full crash report file generated by JVM, but from what you've shared this could be a JIT compilation related issue. Could you try setting cairo.sql.jit.mode=off (or override CairoConfiguration#getSqlJitMode() to return SqlJitMode.JIT_MODE_DISABLED in your embedded code)?

matyasberry commented 7 months ago

is it possible to set it using -Dcairo.sql.jit.mode=off ?

puzpuzpuz commented 7 months ago

No, but if you're using PropServerConfiguration as the configuration class, it should be possible to set it via QDB_CAIRO_SQL_JIT_MODE=off environment variable.

matyasberry commented 7 months ago

Disabling JIT helped. No crash any more. What kind of 'cost' or impact are we looking at?

puzpuzpuz commented 7 months ago

JIT-compiled filters are 2-10x faster than the Java ones.

matyasberry commented 7 months ago

Applies to 7.4.0 and 7.4.2 too