Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw CURRENT_WRITE_BUFFER_IS_EXHAUSTED for normal behaviour #48288

Merged

Conversation

Algunenano
Copy link
Member

Changelog category (leave one):

  • Improvement

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

  • Don't throw CURRENT_WRITE_BUFFER_IS_EXHAUSTED for normal behaviour

Documentation entry for user-facing changes

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

While testing 23.3 settings http_wait_end_of_query and http_response_buffer_size I noticed the following error on system.errors only (queries finished correcly):

Row 1:
──────
server_shard:       1
version:            23.3.1.2778
name:               CURRENT_WRITE_BUFFER_IS_EXHAUSTED
code:               362
quantity:           20
last_error_message: MemoryWriteBuffer limit is exhausted
traceback:          DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool)
DB::MemoryWriteBuffer::addChunk()
DB::CascadeWriteBuffer::nextImpl()
DB::ParallelFormattingOutputFormat::collectorThreadFunction(std::__1::shared_ptr<DB::ThreadGroupStatus> const&)
void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<true>::ThreadFromGlobalPoolImpl<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'(), void ()>>(std::__1::__function::__policy_storage const*)
ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>)

Looking at the exception it seems that CH uses CURRENT_WRITE_BUFFER_IS_EXHAUSTED to internally flag in CascadeWriteBuffer that it needs a new buffer. The problem is that using DB::Exception also reports this error to system.errors which is confusing since this is not an actual error.

Instead, use a custom exception to handle it this and only throw CURRENT_WRITE_BUFFER_IS_EXHAUSTED when there are no buffers anymore.

@robot-ch-test-poll robot-ch-test-poll added the pr-improvement Pull request with some product improvements label Mar 31, 2023
@alexey-milovidov
Copy link
Member

Ok, but can we avoid using exceptions in this case?

@Algunenano
Copy link
Member Author

AFAICS, only by rewriting CascadeWriteBuffer completely and changing WriteBuffer::next(), which is used pretty much everywhere, so it can flag this situation.

@alexey-milovidov alexey-milovidov self-assigned this Apr 3, 2023
@alexey-milovidov alexey-milovidov merged commit 3e182bb into ClickHouse:master Apr 3, 2023
138 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants