Fix stack overflow in recursive Buffer tables.#40643
Fix stack overflow in recursive Buffer tables.#40643alexey-milovidov merged 7 commits intomasterfrom
Conversation
| if (underlying) | ||
| underlying_rows = underlying->totalRows(settings); | ||
| if (!underlying_rows) | ||
| return underlying_rows; |
There was a problem hiding this comment.
Indeed, nice catch! (Thread can be resolved).
src/Storages/StorageBuffer.cpp
Outdated
| { | ||
| std::optional<UInt64> underlying_rows; | ||
| auto underlying = DatabaseCatalog::instance().tryGetTable(destination_id, getContext()); | ||
| auto destination = DatabaseCatalog::instance().tryGetTable(destination_id, getContext()); |
There was a problem hiding this comment.
Maybe add a helper to get destination, like in #40640?
| DROP TABLE IF EXISTS test; | ||
| CREATE TABLE test (key UInt32) Engine = Buffer(currentDatabase(), test, 16, 10, 100, 10000, 1000000, 10000000, 100000000); | ||
| SELECT * FROM test; -- { serverError 269 } | ||
| SELECT * FROM system.tables WHERE table = 'test' AND database = currentDatabase() FORMAT Null; -- { serverError 269 } |
There was a problem hiding this comment.
Note, that concurrent run this test with select * from system.tables queries (in some other tests) may produce INFINITE_LOOP errors there, but maybe this test should be run in parallel, and instead tests that do select * from system.tables should not.
Simple queries takes too much time, I'm pretty sure that there are some hung tasks reported by the kernel, maybe dmesg should be captured for all tests (just in case). Will take a look at OOM Bad report, #40655 should help There is a data-race between reading in |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix stack overflow in recursive
Buffertables. This closes #40637