Skip to content

caching touch() queries and re-using the plans causing segfault #6560

@nwoolmer

Description

@nwoolmer

To reproduce

CREATE TABLE t1 AS (
  SELECT generate_series as t, 
         (generate_series % 123456)::int as i 
  FROM generate_series('2025-12-25', '2025-12-26', '1s')
) PARTITION BY DAY WAL;


select touch(select * from t1);

-- works fine

alter table t1 add column f float;

select touch(select * from t1);

-- cached query plan cannot be used because table schema has changed [table=t1', expectedTableId=60408, actualTableId=60408, expectedMetadataVersion=0, actualMetadataVersion=1]
-- get an error, and result, but still ok

select touch(select * from t1);

-- Invalid JSON response from the server: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

-- server segfaulted and process killed

Worse, this persists even after restart. If you try to run select touch(select * from t1); again, it will crash.

server log:

2025-12-18T17:26:06.509789Z I i.q.g.e.QueryProgress exe [id=39, sql=`select touch(select * from t1)`, principal=admin, cache=false, jit=false]
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000011283a8a0, pid=59295, tid=40963
#
# JRE version: OpenJDK Runtime Environment Corretto-17.0.11.9.1 (17.0.11+9) (build 17.0.11+9-LTS)
# Java VM: OpenJDK 64-Bit Server VM Corretto-17.0.11.9.1 (17.0.11+9-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# J 1949 c2 sun.misc.Unsafe.getByte(J)B [email protected] (8 bytes) @ 0x000000011283a8a0 [0x000000011283a880+0x0000000000000020]
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/nick/IdeaProjects/questdb-4/hs_err_pid59295.log
#
# If you would like to submit a bug report, please visit:
#   https://github.com/corretto/corretto-17/issues/

stack trace:

   Current thread (0x000000013e808e00):  JavaThread "shared-network_2" [_thread_in_Java, id=40963, stack(0x0000000176b68000,0x0000000176d6b000)]

Stack: [0x0000000176b68000,0x0000000176d6b000],  sp=0x0000000176d69ad0,  free space=2054k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
J 1949 c2 sun.misc.Unsafe.getByte(J)B [email protected] (8 bytes) @ 0x000000011283a8a0 [0x000000011283a880+0x0000000000000020]
j  io.questdb.griffin.engine.functions.table.TouchTableFunctionFactory$TouchTableFunc.touchMemory(JJJ)J+30 [email protected]
j  io.questdb.griffin.engine.functions.table.TouchTableFunctionFactory$TouchTableFunc.touchTable()V+104 [email protected]
j  io.questdb.griffin.engine.functions.table.TouchTableFunctionFactory$TouchTableFunc.getStr(Lio/questdb/std/str/Utf16Sink;)V+1 [email protected]
j  io.questdb.griffin.engine.functions.table.TouchTableFunctionFactory$TouchTableFunc.getStrA(Lio/questdb/cairo/sql/Record;)Ljava/lang/CharSequence;+12 [email protected]
j  io.questdb.cairo.sql.VirtualFunctionRecord.getStrA(I)Ljava/lang/CharSequence;+9 [email protected]
J 3926 c2 io.questdb.cutlass.http.processors.JsonQueryProcessorState.doQueryRecord(Lio/questdb/cutlass/http/HttpChunkedResponse;I)V [email protected] (814 bytes) @ 0x00000001129ae170 [0x00000001129ad5c0+0x0000000000000bb0]
j  io.questdb.cutlass.http.processors.JsonQueryProcessorState.doRecordFetchLoop(Lio/questdb/cutlass/http/HttpChunkedResponse;I)V+8 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessorState.onResumeSendRecordsLoop(Lio/questdb/cutlass/http/HttpChunkedResponse;I)V+10 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessorState.onResumeQueryPrefix(Lio/questdb/cutlass/http/HttpChunkedResponse;I)V+22 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessorState.onResumeSetupFirstRecord(Lio/questdb/cutlass/http/HttpChunkedResponse;I)V+27 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessorState$$Lambda$584+0x000000040166ae10.onResume(Lio/questdb/cutlass/http/HttpChunkedResponse;I)V+6 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessorState.resume(Lio/questdb/cutlass/http/HttpChunkedResponse;)V+19 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.doResumeSend(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;Lio/questdb/cutlass/http/HttpConnectionContext;)V+37 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.executeSelect0(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;Lio/questdb/cairo/sql/RecordCursorFactory;Z)V+59 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.executeSelect(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;Lio/questdb/cairo/sql/RecordCursorFactory;)V+4 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.executeNewSelect(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;Lio/questdb/griffin/CompiledQuery;Ljava/lang/CharSequence;)V+8 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor$$Lambda$495+0x000000040163f030.execute(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;Lio/questdb/griffin/CompiledQuery;Ljava/lang/CharSequence;)V+7 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.compileAndExecuteQuery(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;)V+108 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.execute0(Lio/questdb/cutlass/http/processors/JsonQueryProcessorState;)V+189 [email protected]
j  io.questdb.cutlass.http.processors.JsonQueryProcessor.onRequestComplete(Lio/questdb/cutlass/http/HttpConnectionContext;)V+69 [email protected]
j  io.questdb.cutlass.http.HttpConnectionContext.handleClientRecv(Lio/questdb/cutlass/http/HttpRequestProcessorSelector;Lio/questdb/cutlass/http/RescheduleContext;)Z+789 [email protected]
j  io.questdb.cutlass.http.HttpConnectionContext.handleClientOperation(ILio/questdb/cutlass/http/HttpRequestProcessorSelector;Lio/questdb/cutlass/http/RescheduleContext;)Z+39 [email protected]
j  io.questdb.cutlass.http.HttpServer.handleClientOperation(Lio/questdb/cutlass/http/HttpConnectionContext;ILio/questdb/cutlass/http/HttpRequestProcessorSelector;Lio/questdb/cutlass/http/WaitProcessor;Lio/questdb/network/IODispatcher;)Z+5 [email protected]
j  io.questdb.cutlass.http.HttpServer$1.lambda$$0(ILio/questdb/cutlass/http/HttpConnectionContext;Lio/questdb/network/IODispatcher;)Z+18 [email protected]
j  io.questdb.cutlass.http.HttpServer$1$$Lambda$489+0x0000000401638670.onRequest(ILio/questdb/network/IOContext;Lio/questdb/network/IODispatcher;)Z+10 [email protected]
J 3688 c2 io.questdb.cutlass.http.HttpServer$1.run(ILio/questdb/mp/Job$RunStatus;)Z [email protected] (36 bytes) @ 0x0000000112964510 [0x0000000112964100+0x0000000000000410]
J 3514% c2 io.questdb.mp.Worker.run()V [email protected] (974 bytes) @ 0x000000011290ab50 [0x000000011290aa80+0x00000000000000d0]
v  ~StubRoutines::call_stub
V  [libjvm.dylib+0x48e248]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x38c
V  [libjvm.dylib+0x48d214]  JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x11c
V  [libjvm.dylib+0x48d2e0]  JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, JavaThread*)+0x64
V  [libjvm.dylib+0x5477b8]  thread_entry(JavaThread*, JavaThread*)+0xc4
V  [libjvm.dylib+0x9d6af4]  JavaThread::thread_main_inner()+0x150
V  [libjvm.dylib+0x9d50fc]  Thread::call_run()+0xcc
V  [libjvm.dylib+0x7f9280]  thread_native_entry(Thread*)+0x158
C  [libsystem_pthread.dylib+0x6f94]  _pthread_start+0x88


siginfo: si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x0000000000000000

QuestDB version:

9.2.2+

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

MacOS

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

APFS

Full Name:

Nick Woolmer

Affiliation:

QuestDB

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

  • Yes, I have

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect or unexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions