duckdb / duckdb-wasm

WebAssembly version of DuckDB
https://shell.duckdb.org
MIT License
1.03k stars 113 forks source link

Error setting temp_directory #1576

Open adityawarmanfw opened 6 months ago

adityawarmanfw commented 6 months ago

What happens?

Setting up a temporary directory leads to Invalid Error: tried to read past the end and Invalid Error: tried to read past the end.

To Reproduce

There are two different error messages:

First, https://shell.duckdb.org/#queries=v0,SET-temp_directory%3D'tmp'~,CREATE-TABLE-tbl-AS--SELECT-range-i%2C-range-j-FROM-range(100000000)~,SELECT-max(i)%2C-max(t1.j)%2C-max(t2.j)%2C-FROM-tbl-AS-t1-JOIN-tbl-AS-t2-USING-(i)~%0A

Leads to Invalid Error: HTML FileReaders do not support writing.

Second, https://shell.duckdb.org/#queries=v0,ATTACH-'x.db'~,USE-x~,SET-temp_directory%3D'tmp'~,CREATE-TABLE-tbl-AS--SELECT-range-i%2C-range-j-FROM-range(100000000)~,SELECT-max(i)%2C-max(t1.j)%2C-max(t2.j)%2C-FROM-tbl-AS-t1-JOIN-tbl-AS-t2-USING-(i)~

Leads to Invalid Error: tried to read past the end

Browser/Environment:

Chrome Version 120.0.6099.199 (Official Build) (arm64)

Device:

Macbook Air M1

DuckDB-Wasm Version:

@duckdb/duckdb-wasm@1.28.1-dev81.0

DuckDB-Wasm Deployment:

shell.duckdb.org

Full Name:

Fidocia Wima Adityawarman

Affiliation:

Sekuel

carlopi commented 6 months ago

Thanks a lot for opening this, I think the interface temporary files are using is a bit wider than the one used by other files (read side should be fine, but write side is mostly done all at once or in some other regular pattern). I will have to debug this, idea is that this should made it work properly.

Connected discussion here: https://github.com/duckdb/duckdb-wasm/discussions/1322

carlopi commented 4 months ago

Adding here since it's a relevant: https://shell.duckdb.org/#queries=v0,ATTACH-'my_database.db'~,USE-my_database~,LOAD-tpch~,call-dbgen(sf-%3D30-)~,PRAGMA-database_size~

This depending on value of sf will lead to different kinds of crashes, but potentially also to creating a 7.4GB file, so it seems to me some kind of offloading is working but not across all codepaths.