Repository navigation
fix(database): treat max_num_threads=0 and buffer_pool_size=0 as the engine default - #83
Merged
adsharma merged 1 commit intoNov 28, 2026
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, evenRETURN 1.buffer_pool_size=0raisedRuntimeError: 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,
PyDatabasestarts fromSystemConfig()and then assigns each value that is set. Only theSystemConfigconstructor turns 0 into the default for these two settings, so a 0 assigned afterwards stayed 0. Withmax_num_threads=0, the task scheduler started no worker threads. The pybind constructor now skips 0 forbuffer_pool_sizeandmax_num_threads, as the Java and Rust bindings do. The C-API backend already got the default, becauselbug_database_initpasses the values through the constructor. The docstrings now say that 0 means the engine default.Tests.
test_database_zero_setting_uses_engine_defaultopens a database with each setting at 0. It checks thatcurrent_setting('threads')andbm_info()'smem_limitmatch a database opened without that setting. Onmain, 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_configchecks that a non-zeromax_num_threadsis 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 madetest_fsm_reclaim_rel_group_columnfail its 8 TiB mmap in every full run. Full suites: no failures on either backend.Fixes #82