Repository navigation
fix(main): reject setting values that would wrap, and map threads=0 - #1453
Open
555aaditya wants to merge 1 commit into
Open
555aaditya wants to merge 1 commit into
555aaditya wants to merge 1 commit into
Conversation
`CALL threads=0` stored 0 threads, after which the next parallel query never finished. Connection::setMaxNumThreadForExec already treats 0 as the database's thread count; the setting now does the same. checkpoint_threshold, sparse_frontier_threshold, var_length_extend_max_depth and recursive_pattern_factor take INT64 but are stored unsigned (the last two as 32 bits), so negative or oversized values wrapped: checkpoint_threshold=-1 read back as 18446744073709551615 (silently disabling auto-checkpoint) and var_length_extend_max_depth=-1 as 4294967295. Reject them with the same "must be >= 0" error physical_plan_pool_per_thread uses.
This branch has not been deployed
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.
Description
Bug 1:
CALL threads=0hangs the next parallel query.ThreadsSetting::setContextstored 0 as the connection's thread count.ClientContext::setMaxNumThreadForExec(0), the C++ API equivalent, already maps 0 to the database'smaxNumThreads. The setting now does the same.Bug 2: four INT64 settings silently wrap. These settings take an INT64 but store it unsigned, two of them as 32 bits:
CALL …thencurrent_setting(…)maincheckpoint_threshold=-118446744073709551615Runtime exception: checkpoint_threshold must be >= 0, got -1.var_length_extend_max_depth=-14294967295… must be >= 0, got -1.var_length_extend_max_depth=4294967296uint32_tfield; not run)… must be <= 4294967295, got 4294967296.recursive_pattern_factor=-54294967291… must be >= 0, got -5.sparse_frontier_threshold=-1uint64_tfield; not run)… must be >= 0, got -1.checkpoint_threshold=-1effectively turns auto-checkpoint off without saying so.Fix. One helper in
settings.cpp,toUnsignedSetting<T>, rejects a value below 0 or aboveT's maximum. The wording matches the existingphysical_plan_pool_per_thread must be >= 0, got N.check. The upper-bound check is compiled only for 32-bit fields (if constexpr), so GCC's-Wtype-limitsdoesn't see an always-false comparison. Valid values, including0(used bycheckpoint_threshold=0in several tests), behave as before. A rejected value leaves the previous setting in place.I didn't find an existing issue for this.
Tests. New
test/test_files/function/call/setting_ranges.test:ThreadsZeroUsesDatabaseThreadCount:CALL threads=0, then a parallelUNWIND … sum(x). Onmainthis case hangs instead of failing.UnsignedSettingsRejectValuesThatWrap: the five rejections above, plus valid values still being applied and read back. Onmainthe rejection statements succeed (Which is: ""against each expected error).Types of changes
Checklist
Validation
macOS 27.0 arm64, Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2, release build (
make test-build-releasewith OpenSSL 3).e2e_test function/call/setting_ranges.test: 2/2 passed. Onmain,UnsignedSettingsRejectValuesThatWrapfails (each rejection succeeds), andThreadsZeroUsesDatabaseThreadCounthangs.main:checkpoint_threshold=-1→18446744073709551615,var_length_extend_max_depth=-1→4294967295,recursive_pattern_factor=-5→4294967291.CALL threads=0; UNWIND range(1,100000) AS x RETURN sum(x)produced no output until I killed it after 15 s (exit 142, SIGALRM).e2e_test --gtest_filter="function~call~*:transaction~*:recursive_join~*:function~gds~*": 569/569 passed.ctest --test-dir build/release/test -j10: 3228/3229 passed. The one failure,dictionary_bug~orb383_relationship_projection_obfuscated.AnonymousParquetDeleteReload, needs a parquet fixture that CI generates (scripts/generate-dictionary-bug-fixture.py, gitignored) and I didn't generate locally. It is unrelated.clang-format18.1.8 (Homebrewllvm@18)--dry-run --Werroronsettings.cpp: clean. I did not runscripts/run-clang-format-docker.sh.origin/main@9e29cf5ef.if constexprguard, written for-Wtype-limitsbut not compiled with GCC here), sanitizers.Note: #1435 edits the
EnableMVCCSettingfunctions next toRecursivePatternFactorSettinginsettings.cpp, so whichever lands second may need a trivial rebase. The changes don't interact.