Skip to content

fix(database): treat max_num_threads=0 and buffer_pool_size=0 as the engine default - #83

Merged
adsharma merged 1 commit into
LadybugDB:mainfrom
zahariash:fix/zero-thread-and-pool-defaults
Nov 28, 2026
Merged

adsharma merged 1 commit into
LadybugDB:mainfrom
zahariash:fix/zero-thread-and-pool-defaults

Conversation

@zahariash

Copy link
Copy Markdown
Contributor

This work was produced with the help of language models.

On 0.23.0, lb.Database(":memory:", max_num_threads=0) hung on its first statement, even RETURN 1. buffer_pool_size=0 raised RuntimeError: Buffer manager exception: The given buffer pool size should be at least 4096 bytes. On 0.22.3, 0 was the default value of both parameters and meant the engine default.

Fix. Since #77, PyDatabase starts from SystemConfig() and then assigns each value that is set. Only the SystemConfig constructor turns 0 into the default for these two settings, so a 0 assigned afterwards stayed 0. With max_num_threads=0, the task scheduler started no worker threads. The pybind constructor now skips 0 for buffer_pool_size and max_num_threads, as the Java and Rust bindings do. The C-API backend already got the default, because lbug_database_init passes the values through the constructor. The docstrings now say that 0 means the engine default.

Tests. test_database_zero_setting_uses_engine_default opens a database with each setting at 0. It checks that current_setting('threads') and bm_info()'s mem_limit match a database opened without that setting. On main, the pybind backend fails both cases: one on a 60 s timeout, the other on the buffer-pool error. Here both cases pass on pybind and C-API. test_database_max_num_threads_config checks that a non-zero max_num_threads is still applied. Both tests open their databases in a subprocess, so a hang fails the test instead of stalling the suite. There is a second reason on the C-API backend. Databases that earlier tests leave open take most of the address space, at 8 TiB each. An in-process version of the thread test made test_fsm_reclaim_rel_group_column fail its 8 TiB mmap in every full run. Full suites: no failures on either backend.

Fixes #82

…engine default

Since 7827fe7, PyDatabase starts from SystemConfig() and assigns each
set value to its field. Only the SystemConfig constructor turns 0 into
the default for bufferPoolSize and maxNumThreads, so an explicit 0
reached the engine unchanged. max_num_threads=0 left the task scheduler
without workers and every statement hung, and buffer_pool_size=0 failed
with "The given buffer pool size should be at least 4096 bytes". 0 was
the default of both parameters before, and the C-API backend still
passes it through the constructor.

Skip 0 for both settings, as the Java and Rust bindings do, and say so
in the docstrings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adsharma
adsharma merged commit 7d9abc1 into LadybugDB:main Nov 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Database() with max_num_threads=0 hangs every query since 0.23.0

2 participants