【Bug】tiflash 内存超限,Tiflash如何分配查询内存的?

补充报错日志

SegmentReader.cpp:123] ["ErrMsg: Memory limit (total) exceeded caused by 'out of memory quota for data computing' : would use 233.21 GiB for data computing (attempt to allocate chunk of 1049113 bytes), limit of memory for data computing: 226.57 GiB StackTrace \n       0x1c116d1\tDB::TiFlashException::TiFlashException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::TiFlashError const&) [tiflash+29431505]\n                \tdbms/src/Common/TiFlashException.h:250\n       0x1c10c5e\tMemoryTracker::alloc(long, bool) [tiflash+29428830]\n                \tdbms/src/Common/MemoryTracker.cpp:154\n       0x1c108d5\tMemoryTracker::alloc(long, bool) [tiflash+29427925]\n                \tdbms/src/Common/MemoryTracker.cpp:165\n       0x1c108d5\tMemoryTracker::alloc(long, bool) [tiflash+29427925]\n                \tdbms/src/Common/MemoryTracker.cpp:165\n       0x1c2098b\tAllocator<false>::alloc(unsigned long, unsigned long) [tiflash+29493643]\n                \tdbms/src/Common/Allocator.cpp:68\n       0x77117b5\tDB::createReadBufferFromFileBaseByFileProvider(std::__1::shared_ptr<DB::FileProvider> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::EncryptionPath const&, unsigned long, std::__1::shared_ptr<DB::ReadLimiter> const&, DB::ChecksumAlgo, unsigned long, int) [tiflash+124852149]\n                \tdbms/src/Encryption/createReadBufferFromFileBaseByFileProvider.cpp:86\n       0x1b5b5a7\tDB::CompressedReadBufferFromFileProvider<false>::CompressedReadBufferFromFileProvider(std::__1::shared_ptr<DB::FileProvider>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::EncryptionPath const&, unsigned long, std::__1::shared_ptr<DB::ReadLimiter> const&, DB::ChecksumAlgo, unsigned long) [tiflash+28685735]\n                \tdbms/src/Encryption/CompressedReadBufferFromFileProvider.cpp:78\n       0x74ac3c9\tstd::__1::__function::__func<DB::DM::DMFileReader::DMFileReader(std::__1::shared_ptr<DB::DM::DMFile> const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, bool, bool, bool, bool, unsigned long, DB::DM::DMFilePackFilter&&, std::__1::shared_ptr<DB::MarkCache> const&, bool, std::__1::shared_ptr<DB::DM::ColumnCache> const&, unsigned long, unsigned long, std::__1::shared_ptr<DB::FileProvider> const&, std::__1::shared_ptr<DB::ReadLimiter> const&, unsigned long, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, std::__1::shared_ptr<DB::DM::ScanContext> const&)::$_2, std::__1::allocator<DB::DM::DMFileReader::DMFileReader(std::__1::shared_ptr<DB::DM::DMFile> const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, bool, bool, bool, bool, unsigned long, DB::DM::DMFilePackFilter&&, std::__1::shared_ptr<DB::MarkCache> const&, bool, std::__1::shared_ptr<DB::DM::ColumnCache> const&, unsigned long, unsigned long, std::__1::shared_ptr<DB::FileProvider> const&, std::__1::shared_ptr<DB::ReadLimiter> const&, unsigned long, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, std::__1::shared_ptr<DB::DM::ScanContext> const&)::$_2>, void (std::__1::vector<DB::IDataType::Substream, std::__1::allocator<DB::IDataType::Substream> > const&)>::operator()(std::__1::vector<DB::IDataType::Substream, std::__1::allocator<DB::IDataType::Substream> > const&) [tiflash+122340297]\n                \t/usr/local/bin/../include/c++/v1/__functional/function.h:345\n       0x74a2afa\tDB::DM::DMFileReader::DMFileReader(std::__1::shared_ptr<DB::DM::DMFile> const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, bool, bool, bool, bool, unsigned long, DB::DM::DMFilePackFilter&&, std::__1::shared_ptr<DB::MarkCache> const&, bool, std::__1::shared_ptr<DB::DM::ColumnCache> const&, unsigned long, unsigned long, std::__1::shared_ptr<DB::FileProvider> const&, std::__1::shared_ptr<DB::ReadLimiter> const&, unsigned long, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, std::__1::shared_ptr<DB::DM::ScanContext> const&) [tiflash+122301178]\n                \tdbms/src/Storages/DeltaMerge/File/DMFileReader.cpp:238\n       0x749bda7\tDB::DM::DMFileBlockInputStreamBuilder::build(std::__1::shared_ptr<DB::DM::DMFile> const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, std::__1::vector<DB::DM::RowKeyRange, std::__1::allocator<DB::DM::RowKeyRange> > const&, std::__1::shared_ptr<DB::DM::ScanContext> const&) [tiflash+122273191]\n                \tdbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp:57\n       0x7448d94\tDB::DM::StableValueSpace::Snapshot::getInputStream(DB::DM::DMContext const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, std::__1::vector<DB::DM::RowKeyRange, std::__1::allocator<DB::DM::RowKeyRange> > const&, std::__1::shared_ptr<DB::DM::RSOperator> const&, unsigned long, unsigned long, bool, bool, bool, std::__1::vector<std::__1::shared_ptr<std::__1::set<unsigned long, std::__1::less<unsigned long>, std::__1::allocator<unsigned long> > >, std::__1::allocator<std::__1::shared_ptr<std::__1::set<unsigned long, std::__1::less<unsigned long>, std::__1::allocator<unsigned long> > > > > const&, bool) [tiflash+121933204]\n                \tdbms/src/Storages/DeltaMerge/StableValueSpace.cpp:461\n       0x73c5e7e\tDB::DM::Segment::getBitmapFilterInputStream(DB::DM::DMContext const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, std::__1::shared_ptr<DB::DM::SegmentSnapshot> const&, std::__1::vector<DB::DM::RowKeyRange, std::__1::allocator<DB::DM::RowKeyRange> > const&, std::__1::shared_ptr<DB::DM::PushDownFilter> const&, unsigned long, unsigned long) [tiflash+121396862]\n                \tdbms/src/Storages/DeltaMerge/Segment.cpp:2863\n       0x73c3aba\tDB::DM::Segment::getInputStream(DB::DM::ReadMode const&, DB::DM::DMContext const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine> > const&, std::__1::shared_ptr<DB::DM::SegmentSnapshot> const&, std::__1::vector<DB::DM::RowKeyRange, std::__1::allocator<DB::DM::RowKeyRange> > const&, std::__1::shared_ptr<DB::DM::PushDownFilter> const&, unsigned long, unsigned long) [tiflash+121387706]\n                \tdbms/src/Storages/DeltaMerge/Segment.cpp:709\n       0x743c286\tDB::DM::SegmentReadTaskPool::buildInputStream(std::__1::shared_ptr<DB::DM::SegmentReadTask>&) [tiflash+121881222]\n                \tdbms/src/Storages/DeltaMerge/SegmentReadTaskPool.cpp:163\n       0x752624f\tDB::DM::MergedTask::initOnce() [tiflash+122839631]\n                \tdbms/src/Storages/DeltaMerge/ReadThread/MergedTask.cpp:50\n       0x752c98e\tDB::DM::SegmentReader::run() [tiflash+122866062]\n                \tdbms/src/Storages/DeltaMerge/ReadThread/SegmentReader.cpp:153\n       0x752e0d2\tvoid* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (DB::DM::SegmentReader::*)(), DB::DM::SegmentReader*> >(void*) [tiflash+122872018]\n                \t/usr/local/bin/../include/c++/v1/thread:291\n  0x7f8f7a3d9ea5\tstart_thread [libpthread.so.0+32421]\n  0x7f8f79ce8b0d\tclone [libc.so.6+1043213]"] [thread_id=1403]