chdb-io / chdb

chDB is an in-process OLAP SQL Engine ๐Ÿš€ powered by ClickHouse
https://clickhouse.com/docs/en/chdb
Apache License 2.0
2.02k stars 72 forks source link

Using session.query("insert xxx") will stuck #260

Open DanielMao1 opened 2 weeks ago

DanielMao1 commented 2 weeks ago

(you don't have to strictly follow this form)

Describe the situation What exactly works slower than expected?

How to reproduce

Create DB, Table, View in temp session, auto cleanup when session is deleted.

sess = chs.Session() sess.query("CREATE DATABASE IF NOT EXISTS db_xxx ENGINE = Atomic") sess.query("CREATE TABLE IF NOT EXISTS db_xxx.log_table_xxx (x String, y Int) ENGINE = Log;") sess.query("INSERT INTO db_xxx.log_table_xxx VALUES ('a', 1), ('b', 3), ('c', 2), ('d', 5);") sess.query( "CREATE VIEW db_xxx.view_xxx AS SELECT FROM db_xxx.log_table_xxx LIMIT 4;" ) print("Select from view:\n") print(sess.query("SELECT FROM db_xxx.view_xxx", "Pretty"))


**Expected performance**
This code should work but it stucked on `sess.query("INSERT INTO db_xxx.log_table_xxx VALUES ('a', 1), ('b', 3), ('c', 2), ('d', 5);")`

**Additional context**
`uname -a` shows:

Linux ip-172-xx-xx-xx 5.19.0-1029-aws #30~22.04.1-Ubuntu SMP Thu Jul 13 17:17:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

auxten commented 2 weeks ago

Can't reproduce on my Linux. Please open debug log by using:

sess.query("INSERT INTO db_xxx.log_table_xxx VALUES ('a', 1), ('b', 3), ('c', 2), ('d', 5);", "Debug")

and give me the log

l1t1 commented 2 weeks ago

good in my environment

root@localhost:~# python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from chdb import session as chs
>>>
>>> ## Create DB, Table, View in temp session, auto cleanup when session is deleted.
>>> sess = chs.Session()
>>> sess.query("CREATE DATABASE IF NOT EXISTS db_xxx ENGINE = Atomic")

>>> sess.query("CREATE TABLE IF NOT EXISTS db_xxx.log_table_xxx (x String, y Int) ENGINE = Log;")

>>> sess.query("INSERT INTO db_xxx.log_table_xxx VALUES ('a', 1), ('b', 3), ('c', 2), ('d', 5);")

>>> sess.query(
...     "CREATE VIEW db_xxx.view_xxx AS SELECT * FROM db_xxx.log_table_xxx LIMIT 4;"
... )

>>> print("Select from view:\n")
Select from view:

>>> print(sess.query("SELECT * FROM db_xxx.view_xxx", "Pretty"))
   โ”โ”โ”โ”โ”ณโ”โ”โ”โ”“
   โ”ƒ x โ”ƒ y โ”ƒ
   โ”กโ”โ”โ”โ•‡โ”โ”โ”โ”ฉ
1. โ”‚ a โ”‚ 1 โ”‚
   โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ค
2. โ”‚ b โ”‚ 3 โ”‚
   โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ค
3. โ”‚ c โ”‚ 2 โ”‚
   โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ค
4. โ”‚ d โ”‚ 5 โ”‚
   โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”˜
DanielMao1 commented 2 weeks ago

@auxten @l1t1 Thank you for your apply! I tested it again and I found the "stuck" only appears when I using jupyter notebook in vscode (jupyter notebook in web interface is OK, strange to me):

image
auxten commented 2 weeks ago

Oh, I see. It's a known issue #152