[Java] Parquet DatasetFileWriter not completely emptying allocator after finishing a write
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne mit dataset/src/test/java/org/apache/arrow/dataset/file/TestDatasetFileWriter.java und dem im Bericht beschriebenen DatasetFileWriter.write-Aufruf. Reproduziere den Parquet-Fall mit einer Zeile mit writerAllocator und seinen untergeordneten Allocatoren und verfolge anschließend, wann der Speicher im Verhältnis zum Schließen von Writer und Allocator den Wert null erreicht. Als erledigt gilt die Untersuchung, wenn festgestellt wurde, ob es sich um eine erwartete Verwendung oder einen Bibliotheksfehler handelt, und die korrekten Hinweise zum Lebenszyklus dokumentiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the usage question you have. Please include as many useful details as possible.
I'm currently working on a somewhat simple project that processes Parquet files as both input and output:
- Main thread is a Parquet DatasetFactory that reads the file in batches. Here I have a child readerAllocator.
- The main thread schedules a fixed amount of worker threads that do the actual processing. They each have their own child workerAllocator.
- The main thread also schedules a single writer thread that reads (via a custom ArrowReader) a queue of worker thread futures from which to obtain the new VectorSchemaRoot with additional columns. The transfer is done just fine via VectorLoader/Unloader and sent to a child writerArrowReaderAllocator, which is then read by the actual writer's child writerAllocator.
I'll admit that this is my first time using the library and am not completely up to speed with the memory management, so my first reaction to seeing the allocators as an AutoCloseable, was to use Java's try-with-resource syntax to not have to faff about with closing the allocators manually.
Much, much, much more debugging later... I realize this is a terrible idea as the allocator's behavior is not always synced with the different objects (e.g.: DatasetFileWriter) that use them (i.e.: the allocators are not empty by the time the closeable objects are closed).
I would get my output parquet file (first one at least) but then the application would exit abruptly due to closing the allocators too early as they weren't empty.
Insanity set in and I wrote this (absolutely disgusting) piece of code out of desperation (putting it at the very end after the DatasetFileWriter.write call has finished):
boolean childrenEmpty = false;
while (!childrenEmpty) {
childrenEmpty = true;
for (BufferAllocator childAllocator : rootAllocator.getChildAllocators()) {
if (allocator.getAllocatorMemory <= 0) allocator.close();
else childrenEmpty = false;
}
}
and... finally... everything started working... no memory errors anymore...
Doing a simple test with a parquet file of 1 row, it would take the writerAllocator roughly anywhere from 50 to 600 iterations until the allocated memory bytes would be down to 0 and then the allocator could be closed without errors.
I'm pretty I've made mistakes in my design given that this is my first time using the library. However, in every example I've seen (whether it be from random google results, the cookbook, or even Claude Opus), the writer's allocator is handled with a try-with-resource. Heck even the class's test closes the allocator without checking if its empty...
So I would just like to know if there is some hidden known side effect that I haven't read about or if there is some usage guidelines I simply haven't followed.
I'm also open to any alternative suggestions on how to handle the closing of the allocators.
Component(s)
OS: RHEL 9.4
Java version: OpenJDK 26.0.1 (compiling to version 25)
Arrow JAR versions: 19.0.0
Default Memory Allocation Manager: Netty
JVM options: --sun-misc-unsafe-memory-access=allow --add-opens=java.base/java.nio=ALL-UNNAMED
- Vorherrschende Sprache
- Java
- Sterne
- 97
- Forks
- 158
- Ø Merge
- 7 T. 19 Std.
- Gemergte PRs (30 T.)
- 26
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/arrow-java
-
DictionaryEncoder.decode accepts out-of-range dictionary indicesEvtl. vergeben @Arawoof06 hat das vor 48 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
apache/arrow-java#1261 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
ArrowFlightJdbcArray.getArray(index, count) can read past the end of the array sliceEvtl. vergeben @Arawoof06 hat das vor 77 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/arrow-java#1236 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
[Java][JDBC] ClobConsumer writes past VarCharVector data buffer for large CLOBsEvtl. vergeben @Arawoof06 hat das vor 82 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/arrow-java#1230 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Byte-array elements leak in `FromSchemaByteArray()`Evtl. vergeben @PG1204 hat das vor 72 Tagen übernommen. OffenType: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
apache/arrow-java#1205 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
[Java][IPC] AbstractCompressionCodec.compress() writes prefix=0 for empty buffers, incompatible with C++/Python readersEvtl. vergeben @PG1204 hat das vor 73 Tagen übernommen. OffenType: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
apache/arrow-java#1196 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in apache/arrow-java
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
bancolombia/scaffold-clean-architecture#1002 ·
Maintainer antworten meist innerhalb von 1 Tag
-
CalendarEventAttendance/get returns eventAttendanceStatus while the doc says attendanceStatusEvtl. vergeben @chibenwa hat das heute übernommen. Offenbug claude
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
linagora/tmail-backend#2697 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
apache/skywalking#14120 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] Case-insensitive search suggestions miss items when the JVM default locale is TurkishEvtl. vergeben @thswlsqls hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Feature] 关于启动游戏进度条显示的优化Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
HMCL-dev/HMCL#6943 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag