questdb / questdb

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

NPE when executing query through WebConsole #4183

Closed nixer89 closed 9 months ago

nixer89 commented 9 months ago

To reproduce

  1. Create a table like this:
CREATE TABLE 'offer_exchanges' (pair SYMBOL CAPACITY 100000 INDEX, rate DOUBLE, volume_a DOUBLE, volume_b DOUBLE, buyer STRING, seller STRING, taker STRING, provider STRING, autobridged STRING, tx_hash STRING, ledger_index INT, sequence INT, ts TIMESTAMP) TIMESTAMP(ts) PARTITION BY MONTH;
  1. Insert a row:

    insert into offer_exchanges values ('abc', 1.1, 1.1, 1.1, 'abc', 'def', 'zxy', 'a', 'some hash', 'foo', 123, 5, now())
  2. Execute Query:

    WITH first_selection as (SELECT pair, first(rate) AS open, last(rate) AS close, min(rate) AS low, max(rate) AS high, sum(volume_a) AS base_volume, sum(volume_b) AS counter_volume, count(*) AS exchanges  FROM 'offer_exchanges' WHERE ts >= '2024-01-30T15:00:00.000Z'),
    second_selection as (SELECT pair, rate as prev_rate, ts as prev_ts FROM 'offer_exchanges' WHERE ts < '2024-01-30T15:00:00.000Z' and pair in (SELECT pair FROM first_selection) LATEST ON ts PARTITION BY pair) 
    SELECT first_selection.pair, first_selection.open, first_selection.close, first_selection.low, first_selection.high, first_selection.base_volume, first_selection.counter_volume, first_selection.exchanges, second_selection.prev_rate, second_selection.prev_ts from first_selection JOIN second_selection on (pair);
  3. Check QuestDB Logs -> NPE should appear:

    2024-02-01T09:25:04.774923Z C i.q.c.h.p.JsonQueryProcessorState [727] internal error [ex=
    java.lang.NullPointerException: Cannot invoke "io.questdb.cairo.sql.StaticSymbolTable.keyOf(java.lang.CharSequence)" because "symbolTable" is null
        at io.questdb.griffin.engine.table.LatestBySubQueryRecordCursorFactory$DataFrameRecordCursorWrapper.buildSymbolKeys(LatestBySubQueryRecordCursorFactory.java:225)
        at io.questdb.griffin.engine.table.LatestBySubQueryRecordCursorFactory$DataFrameRecordCursorWrapper.hasNext(LatestBySubQueryRecordCursorFactory.java:165)
        at io.questdb.griffin.engine.table.SelectedRecordCursor.hasNext(SelectedRecordCursor.java:80)
        at io.questdb.cairo.TableUtils.populateRowIDHashMap(TableUtils.java:1213)
        at io.questdb.griffin.engine.join.HashJoinLightRecordCursorFactory$HashJoinRecordCursor.buildMapOfSlaveRecords(HashJoinLightRecordCursorFactory.java:193)
        at io.questdb.griffin.engine.join.HashJoinLightRecordCursorFactory$HashJoinRecordCursor.hasNext(HashJoinLightRecordCursorFactory.java:148)
        at io.questdb.griffin.engine.table.SelectedRecordCursor.hasNext(SelectedRecordCursor.java:80)
        at io.questdb.griffin.engine.RegisteredRecordCursorFactory$RegisteredRecordCursor.hasNext(RegisteredRecordCursorFactory.java:198)
        at io.questdb.cutlass.http.processors.JsonQueryProcessorState.setupFirstRecord(JsonQueryProcessorState.java:825)
        at io.questdb.cutlass.http.processors.JsonQueryProcessorState.onSetupFirstRecord(JsonQueryProcessorState.java:784)
        at io.questdb.cutlass.http.processors.JsonQueryProcessorState.resume(JsonQueryProcessorState.java:932)
        at io.questdb.cutlass.http.processors.JsonQueryProcessor.doResumeSend(JsonQueryProcessor.java:317)
        at io.questdb.cutlass.http.processors.JsonQueryProcessor.executeSelect(JsonQueryProcessor.java:573)
        at io.questdb.cutlass.http.processors.JsonQueryProcessor.executeNewSelect(JsonQueryProcessor.java:537)
        at io.questdb.cutlass.http.processors.JsonQueryProcessor.compileAndExecuteQuery(JsonQueryProcessor.java:445)
        at io.questdb.cutlass.http.processors.JsonQueryProcessor.execute0(JsonQueryProcessor.java:189)
        at io.questdb.cutlass.http.processors.JsonQueryProcessor.onRequestComplete(JsonQueryProcessor.java:247)
        at io.questdb.cutlass.http.HttpConnectionContext.handleClientRecv(HttpConnectionContext.java:869)
        at io.questdb.cutlass.http.HttpConnectionContext.handleClientOperation(HttpConnectionContext.java:253)
        at io.questdb.cutlass.http.HttpServer$1.lambda$$0(HttpServer.java:81)
        at io.questdb.network.AbstractIODispatcher.processIOQueue(AbstractIODispatcher.java:199)
        at io.questdb.cutlass.http.HttpServer$1.run(HttpServer.java:85)
        at io.questdb.mp.Worker.run(Worker.java:148)

QuestDB version:

7.3.9

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

Ubuntu 22.04

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

ext4

Full Name:

Daniel Siedentopf

Affiliation:

XRP Ledger Foundation

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

Additional context

No response

nixer89 commented 8 months ago

The fix works. The error does not appear anymore. Thank you!