exec_mem_limit is a session variable, which can be set by users. I think we should define it exactly to make users understood. For example , It is max memory consumption of a query on a be. If a query consumes memory beyond exec_mem_limit on a be , it should be failed due to memory allocation.
I am not sure whether the above idea is acceptable. Now, exec_mem_limit does not work because some memory allocation is not limited by it due to calling MemPool::allocate. Actually exec_mem_limit works at fragment instance level, it does not work at query level. However, FragmentInstance is related to table, users can not expect how many fragment instances would run on a be, so it is difficult to make users understood. Should we let exec_mem_limit limit memory consumption on a query on a be? The same message is put on discussion. https://github.com/StarRocks/starrocks/discussions/4069