Aggregate spill: List<Dictionary> state whose values repeat within a group still fails under a memory limit
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 53/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Domaine
- data-engineering, databases
Piste de recherche
Start with #25853 and the spill and replay handling for List<Dictionary> state, especially how SpilledRowSizes estimates referenced values. Reproduce the failure with the provided datafusion-cli -m 24M query, then trace the aggregate spill path and its tests. Done means the query completes under a limit sufficient for one group without causing excessive spill growth when groups share values.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
An aggregate whose state holds a large dictionary can still fail with Failed to allocate additional ... after #25853 (which fixes #25851), when the dictionary values repeat within a group but not across groups. #25853 sizes a dictionary by the values its keys reference only when fewer than two keys reference each value on average; otherwise it counts the keys only and leaves the dictionary shared, as on main. A dictionary whose values repeat a few times within a group, but whose groups share no values, takes the shared path, and spill and replay batches still carry the whole dictionary.
To Reproduce
Measured with datafusion-cli (release-nonlto) at the head of #25853 (29c666126):
SET datafusion.execution.target_partitions = 1;
SELECT count(*), sum(n) FROM (
SELECT (v / 10) % 32 AS k,
cardinality(array_agg(arrow_cast(concat(CAST(v / 10 AS VARCHAR), repeat('x', 100)), 'Dictionary(Int32, Utf8)'))) AS n
FROM generate_series(1, 5000000) AS t(v)
GROUP BY (v / 10) % 32);
datafusion-cli -m 24M fails with Failed to allocate additional 24.7 MB for SingleHashAggregateStream[0] with 0.0 B already allocated for this reservation. It passes at -m 64M.
Changing only how often each value repeats in a group (v / 10 in both places):
| repeats per value | -m 24M |
|---|---|
| 2 | passes |
| 10 | fails |
| 50 | passes |
With 1000-byte values and target_partitions = 2, the final aggregate fails at -m 24M (Failed to allocate additional 16.8 MB for FinalHashAggregateStream[0]). With 1000-byte values and target_partitions = 1 over 2M rows, it fails at both 24M and 64M.
Expected behavior
The query completes under a memory limit large enough for one group, as the other repeat counts do.
Additional context
Compacting the dictionary of each spilled chunk would be cheap here, but whether it pays off depends on whether the groups share their values. If they do, each chunk writes its own copy and the spill file grows, which is why #25853 doesn't compact every dictionary (array_agg over 100 distinct 200-byte values spilled 371 MB, against 14.7 MB without compaction). Telling the two cases apart needs the number of distinct values referenced per row, which SpilledRowSizes doesn't track for List<Dictionary>.
Related: #25851, #25853, #26711.
Willingness to contribute
I would like to contribute a fix for this bug, but request guidance from the DataFusion community
- Langage dominant
- Rust
- Étoiles
- 9.6k
- Forks
- 2.6k
- Merge moyen
- 3 j 4 h
- PR mergées (30 j)
- 345
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/datafusion
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/datafusion#27315 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
apache/datafusion#27094 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlPeut-être pris @jonasHanhan l’a pris il y a 9 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
apache/datafusion#27059 ·
Les mainteneurs répondent en général sous 1 jour
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsPeut-être pris @joseph-isaacs l’a pris il y a 10 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/datafusion#27050 ·
Les mainteneurs répondent en général sous 1 jour
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsPeut-être pris @geoHeil l’a pris il y a 8 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
apache/datafusion#26999 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de apache/datafusion
Issues similaires
-
P3
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
HerringtonDarkholme/hd-lang#1770 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
jonathanong/no-mistakes#3332 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
swc-project/swc-next-issues#310 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
swc-project/swc-ai-issues#653 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
lbjlaq/Antigravity-Manager#3937 ·
Les mainteneurs répondent en général sous 1 jour