Skip to content

Implement the max_insert_block_size_bytes setting for Format Pasing - #92833

Merged
Fgrtue merged 11 commits into
masterfrom
max-insert-block-size-bytes-format-parsing
Dec 30, 2025
Merged

Fgrtue merged 11 commits into
masterfrom
max-insert-block-size-bytes-format-parsing

Conversation

@Fgrtue

@Fgrtue Fgrtue commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor

Changelog category:

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Adds new setting max_insert_block_size_bytes which control the formation of inserted blocks in finer detail.

Resolved step 1 and 2 from the comment #42515 (comment) in #42515.

New settings for Block Formation Control

  • Added an alias for max_insert_block_size -- max_insert_block_size_rows
  • Added new setting max_insert_block_size_bytes with which user can now control the formation of blocks in finer detail
  • Propagated min_insert_block_size_rows and min_insert_block_size_bytes to format parsing so that users can control the formation of blocks during parsing using lower bounds.

What is covered

These settings now control block formation in Format parsing, when data is being parsed from row-based formats (CSV, TSV, JSONEachRow, etc.) and Values format via:

  • clickhouse-client
  • clickhouse-server using HTTP interface
  • gRPC and PostgreSQL wire protocol interfaces

Block Formation Logic

A block is emitted when either of these conditions is met:

  1. Min thresholds (AND): Both min_insert_block_size_rows AND min_insert_block_size_bytes are reached
  2. Max thresholds (OR): Either max_insert_block_size_rows OR max_insert_block_size_bytes is reached

Disabling settings: Set max_insert_block_size_bytes, min_insert_block_size_rows, or min_insert_block_size_bytes to 0 to disable. The setting will not participate in block formation decisions.

Note: max_insert_block_size_rows should remain non-zero still as it's used in other parts of code, for example in streaming engines.

Limitations and future plans

Setting max_insert_block_size_bytes is not supported in streaming engines (e.g. FileLog, Kafka, RabbitMQ, NATS), since there is no yet max_block_size_bytes setting in these engines to override. Once it is clear how to add it, it will be possible to add max_insert_block_size as a fallback setting.

It is also planned to change the conditions for squashing, making not only min_insert_block_size_rows and min_insert_block_size_bytes to be applied, but also add the formation of blocks using max as an upper bound.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [89b7e4a]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan, targeted) failure
03708_flush_async_insert_queue_for_table FAIL cidb IGNORED
Integration tests (amd_asan, db disk, old analyzer, 1/6) failure
test_storage_s3_queue/test_5.py::test_failure_in_the_middle FAIL cidb, issue ISSUE CREATED
test_storage_s3_queue/test_5.py::test_disable_streaming FAIL cidb, issue ISSUE CREATED
Integration tests (arm_binary, distributed plan, 2/4) failure
test_userspace_page_cache/test.py::test_size_adjustment FAIL cidb, issue ISSUE EXISTS
Integration tests (arm_binary, distributed plan, 3/4) failure
test_peak_memory_usage/test.py::test_clickhouse_client_max_peak_memory_usage_distributed FAIL cidb, issue ISSUE EXISTS
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting in ExpressionList: the query: (STID: 1941-1bfa) FAIL cidb, issue ISSUE CREATED

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Dec 22, 2025
@yariks5s yariks5s self-assigned this Dec 22, 2025
@yariks5s
yariks5s requested a review from Copilot December 25, 2025 22:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements byte-based block size control for format parsing by adding max_insert_block_size_bytes setting and propagating min/max thresholds to row input formats. The feature enables users to control block formation during data parsing from row-based formats (CSV, TSV, JSONEachRow, Values) across HTTP, gRPC, PostgreSQL wire protocol, and client interfaces.

Key changes:

  • Added max_insert_block_size_bytes setting and max_insert_block_size_rows alias for max_insert_block_size
  • Propagated min_insert_block_size_rows and min_insert_block_size_bytes to format parsing
  • Updated block formation logic to use AND for min thresholds, OR for max thresholds

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Core/Settings.cpp Added new settings definitions and updated documentation for block size control
src/Core/SettingsChangesHistory.cpp Registered new settings in version 26.1
src/Formats/FormatFactory.h Added optional parameters for byte/row thresholds to getInput
src/Formats/FormatFactory.cpp Updated to accept and apply new block size parameters
src/Processors/Formats/IRowInputFormat.h Extended RowInputFormatParams with min/max byte/row thresholds
src/Processors/Formats/IRowInputFormat.cpp Implemented new block formation logic with min/max threshold checks
src/Processors/Formats/Impl/ValuesBlockInputFormat.cpp Updated to use max_block_size_rows instead of max_block_size
src/Processors/Sources/YTsaurusSource.cpp Renamed parameter from max_block_size to max_block_size_rows
src/Interpreters/Context.h Extended getInputFormat signature with new optional parameters
src/Interpreters/Context.cpp Updated getInputFormat implementation to forward new parameters
src/Client/ClientBase.h Added config fields for all four block size thresholds
src/Client/ClientBase.cpp Updated to read config values and pass all thresholds to format creation
src/Client/LocalConnection.cpp Updated to pass settings for byte/row thresholds
src/Server/GRPCServer.cpp Updated format creation calls with new settings
src/Server/PostgreSQLHandler.cpp Updated format creation with new settings parameters
src/Processors/Transforms/getSourceFromASTInsertQuery.cpp Updated to pass new settings to format creation
tests/queries/0_stateless/03722_max_insert_block_size_bytes_client_row_format.sql Test verifying block formation with different threshold combinations via client
tests/queries/0_stateless/03722_max_insert_block_size_bytes_client_row_format.reference Expected results showing correct part counts
tests/queries/0_stateless/03723_max_insert_block_size_bytes_http.sh Test verifying block formation via HTTP interface
tests/queries/0_stateless/03723_max_insert_block_size_bytes_http.reference Expected results for HTTP test
Comments suppressed due to low confidence (1)

src/Core/Settings.cpp:118

  • The comment line at 62 says "Disable max_insert_block_bytes" but the setting name is actually "max_insert_block_size_bytes". This inconsistency could confuse users.
)", 0) \

Comment thread src/Core/SettingsChangesHistory.cpp Resolved
@Fgrtue
Fgrtue added this pull request to the merge queue Dec 30, 2025
@Fgrtue

Fgrtue commented Dec 30, 2025

Copy link
Copy Markdown
Contributor Author

Failure of Stateless tests (arm_asan, targeted) (cidb) was an issue: #93051 and got resolved in #93227

@clickgapai

Copy link
Copy Markdown
Contributor

Hi @Fgrtue @yariks5s — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants