[Bug] BE aborts via std::terminate when a VARIANT read exceeds the query memory limit (allocation in noexcept release path)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
Línea de trabajo
Start at release_batch_container in be/src/core/value/variant/variant_batch_builder.cpp (around line 134) and at _take_encoded_metadata() (around line 342), then check the noexcept functions there that call it, including release_scratch(). Run or write a test that drives the VARIANT V2 assembly path under a tight memory tracker limit. Done means the query returns MEM_LIMIT_EXCEEDED without the BE terminating, and the noexcept release paths no longer allocate.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Search before asking
- I had searched in the issues and found no similar issues.
Version
4.1.4 (cloud mode, arm64); master is the same. On master release_batch_container is be/src/core/value/variant/variant_batch_builder.cpp:134 and _take_encoded_metadata() is :342.
What's Wrong?
A query that reads a VARIANT V2 column and exceeds its memory limit aborts the BE process with std::terminate, instead of failing the query with MEM_LIMIT_EXCEEDED. When the query runs on every BE, every BE aborts at once. In our case all 4 BEs aborted within about 10 s and restarted.
FE error for the query: [MEM_ALLOC_FAILED]Allocator mem tracker check failed, [MEM_LIMIT_EXCEEDED]failed alloc size 13.68 MB.
Symbolized BE stack:
#0 std::terminate handler
#3 __clang_call_terminate
#4 doris::VariantMetadataBuilder::_take_encoded_metadata() (allocation, core/custom_allocator.h:133)
#5 doris::VariantBatchBuilder::finish_batch() (core/value/variant/variant_batch_builder.cpp:1728)
#6 doris::segment_v2::variant_v2::VariantAssembler::assemble(...)
... segment iterator / scan operator frames
Cause:
template <typename Container>
void release_batch_container(Container& container) noexcept {
Container().swap(container);
}
PaddedPODArray<char> VariantMetadataBuilder::_take_encoded_metadata() noexcept {
...
release_batch_container(_impl->keys); // Keys = std::deque<PaddedPODArray<char>, CustomStdAllocator<...>>
...
}
A default-constructed libstdc++ std::deque allocates its map and first node. With CustomStdAllocator, that allocation goes through MemoryAllocator::alloc, which throws doris::Exception (MEM_ALLOC_FAILED, "Allocator mem tracker check failed") once the thread's memory tracker is over its limit. The throw happens inside a noexcept function, so the runtime calls std::terminate. release_scratch() is also noexcept and uses the same helper. Other noexcept functions in this file may allocate as well, and are worth auditing for the same pattern.
What You Expected?
The query fails with MEM_LIMIT_EXCEEDED and the BE keeps running.
How to Reproduce?
A table with a VARIANT column (Variant V2) holding about 1B rows of nested JSON. A query that materializes the VARIANT for many rows under the default query memory limit, e.g.:
SELECT count(*), sum(length(j))
FROM (SELECT CAST(v AS STRING) AS j FROM t
WHERE ts >= '...' AND ts < '...'
ORDER BY ts DESC, id LIMIT 1000000) x;
Any query whose VARIANT read pushes the memory tracker over its limit while finish_batch runs should reproduce it. (Separately, the CAST is evaluated in the scan projection for every row before the top-N, rather than being deferred by lazy materialization. That makes this query far more memory-hungry than its LIMIT suggests.)
Anything Else?
Possible fix: make the release path unable to allocate or throw. For example, fall back to clear() when constructing an empty container throws, or drop noexcept where no caller relies on it, so the memory-limit exception reaches the query as a normal error.
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
- Lenguaje dominante
- Java
- Estrellas
- 16.1k
- Forks
- 4k
- Merge medio
- 2 d 23 h
- PR fusionados (30 d)
- 686
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/doris
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Medio día Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
4.1.4.1 Release NoteAbiertorelease notes
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
[Bug] FE metric http_copy_into_query_err_total is registered under the upload error namePosiblemente ocupada @manesioz la tomó hace 23 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
apache/doris#68505 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/doris
Issues similares
-
NullPointerException when a `DeserializationProblemHandler` returns `null` for `byte[]` (single value unwrapped) and `char[]` elementsPosiblemente ocupada @Marti2203 la tomó hoy. Abierto
Dificultad 2/5 Medio día Aptitud para principiantes 88/100
FasterXML/jackson-databind#6300 ·
Los mantenedores suelen responder en 1 día
-
content good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
cpinitiative/usaco-guide#6699 ·
Los mantenedores suelen responder en 1 día
-
BC remittance upload: a claim MSP refused (S03) is saved with a blank status instead of refused (F)Abiertotype: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
carlos-emr/carlos#4933 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/rocketmq-dashboard#6925 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Vakore/ZappierGames#147 ·