-
Notifications
You must be signed in to change notification settings - Fork 7.8k
fix: fix server level max temporary size limit #87140
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
Conversation
c8af459 to
9d0d6f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix, it's really a great catch! So basically, max_temporary_data_on_disk_size was not properly tested and barely usable. Have you checked by the chance if the metrics were correct before and are now fixed by this change?
| @@ -0,0 +1,35 @@ | |||
| <clickhouse> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be better to add this test case to the integration test suite at https://github.com/ClickHouse/ClickHouse/tree/master/tests/integration/test_temporary_data rather than as a stateless test that runs a separate server. However, this is fine for now - we can refactor it in a separate PR if we decide it's necessary.
| void freeAlloc(); | ||
|
|
||
| TemporaryDataOnDiskScope * parent; | ||
| std::shared_ptr<TemporaryDataOnDiskScope> parent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there cases where TemporaryDataBuffer's lifetime is greater than TemporaryDataOnDiskScope? I assume the initial intent was to keep the buffer's lifetime shorter than the scope lifetime, so I'm asking just to better understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For MergeSortingTransform, its TemporaryDataOnDiskScope is created here.
| tmp_data_on_disk = data->childScope(CurrentMetrics::TemporaryFilesForSort); |
And In MergeSortingTransform, we create tmp_stream use raw pointer of tmp_data
| TemporaryBlockStreamHolder tmp_stream(shared_header_without_constants, tmp_data.get(), reserve_size); |
Subsequently, we use tmp_stream to create BufferingToFileSink. This BufferingToFileSink is destroyed in SortingTransform at a point later than the destruction of MergeSortingTransform, which causes the lifetime of TemporaryDataBuffer to exceed that of TemporaryDataOnDiskScope
| auto sink = std::make_shared<BufferingToFileSink>(shared_header_without_constants, std::move(tmp_stream), log); |
And I also encountered a Fatal error here with raw pointer
Yeah, I have checked the metrics were correct after the fix |
|
@vdimir, can we use |
@alexey-milovidov I initially tried using |
Cherry pick #87140 to 25.9: fix: fix server level max temporary size limit
Cherry pick #87140 to 25.7: fix: fix server level max temporary size limit
Cherry pick #87140 to 25.8: fix: fix server level max temporary size limit
Backport #87140 to 25.9: fix: fix server level max temporary size limit
Backport #87140 to 25.7: fix: fix server level max temporary size limit
Backport #87140 to 25.8: fix: fix server level max temporary size limit
…25.9/87449 * u/backport/25.9/87449: Backport #87426 to 25.9: Ignore only not found errors for s3_plain_rewritable (and some other S3 code) Backport #87231 to 25.9: Fix "Too large size passed to allocator" UB in JOIN due to mixed const and non-const blocks Backport #87198 to 25.9: Disable the setting by default Backport #87392 to 25.9: Fix EmbeddedRocksDB upgrade Backport #87140 to 25.9: fix: fix server level max temporary size limit Backport #87178 to 25.9: PR: fix LEFT/INNER ... RIGHT ... JOINS chain Update autogenerated version to 25.10.1.1 and contributors
Cherry pick #87140 to 25.3: fix: fix server level max temporary size limit
Cherry pick #87140 to 25.6: fix: fix server level max temporary size limit
Backport #87140 to 25.6: fix: fix server level max temporary size limit
Backport #87140 to 25.3: fix: fix server level max temporary size limit
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
max_temporary_data_on_disk_sizelimit tracking, close The statistic value of temporary data size always increases #87118