This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-java.git
The following commit(s) were added to refs/heads/main by this push:
new 54821f9f2 GH-1455: Keep TestReservationListener from closing a pool
still in use (#1457)
54821f9f2 is described below
commit 54821f9f262b64b8dcab3e972644c635f8d644b2
Author: JB Onofré <[email protected]>
AuthorDate: Tue Nov 10 08:52:01 2026 +0000
GH-1455: Keep TestReservationListener from closing a pool still in use
(#1457)
## What's Changed
`TestReservationListener#testErrorThrownFromReservationListener` closes
its listenable `NativeMemoryPool` right after the scan fails. Arrow C++
can still be running the failed scan's work (Parquet file opens,
read-ahead) on its thread pools, and that work keeps allocating from and
freeing to the pool. Freeing the pool under it intermittently crashes
the test JVM in the RC workflow's Binaries job, and surefire reports
`TestAllTypes`, the next test in that JVM, as the crashed test. #1455
has the analysis.
- `testErrorThrownFromReservationListener` leaves the pool open, with a
comment explaining why. The assertion on the reservation after closing
the pool is removed; the one before it stays.
- `TestDataset#collectResultFromFactory` closes the scanner and the
dataset when the scan fails, not only when it succeeds. This alone
doesn't stop the crash, because closing the scanner doesn't wait for
that work.
I looped the test's steps up to 1,000 times per JVM on macOS arm64 with
the `jni-macos-aarch_64` libraries from the RC workflow. With the pool
closed, 11 of 14 runs failed (JVM crash, or a scan that should have
failed succeeded), whether or not the scanner was closed first. With the
pool left open, 10 of 10 runs passed. With this change,
`TestReservationListener` passed in 8 of 8 runs, and the other tests
that use `collectResultFromFactory` pass (`TestFileSystemDataset`,
`TestAllTypes`). I skipped `TestFileSystemDataset#testBaseJsonRead`,
which crashes with the macOS library for an unrelated reason (#1429).
This doesn't fix the library problem that a listenable pool can be freed
while native scan work still uses it. I've described that in #246.
Closes #1455.
---
dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java | 9 +++------
.../org/apache/arrow/dataset/jni/TestReservationListener.java | 6 +++---
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java
b/dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java
index 4b155137e..a97632fe2 100644
--- a/dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java
+++ b/dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java
@@ -68,12 +68,9 @@ public abstract class TestDataset {
protected List<ArrowRecordBatch> collectResultFromFactory(
DatasetFactory factory, ScanOptions options) {
- final Dataset dataset = factory.finish();
- final Scanner scanner = dataset.newScan(options);
- try {
- final List<ArrowRecordBatch> ret = collectTaskData(scanner);
- AutoCloseables.close(scanner, dataset);
- return ret;
+ try (Dataset dataset = factory.finish();
+ Scanner scanner = dataset.newScan(options)) {
+ return collectTaskData(scanner);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
diff --git
a/dataset/src/test/java/org/apache/arrow/dataset/jni/TestReservationListener.java
b/dataset/src/test/java/org/apache/arrow/dataset/jni/TestReservationListener.java
index 9fabc4a25..2ff7ccafb 100644
---
a/dataset/src/test/java/org/apache/arrow/dataset/jni/TestReservationListener.java
+++
b/dataset/src/test/java/org/apache/arrow/dataset/jni/TestReservationListener.java
@@ -122,9 +122,9 @@ public class TestReservationListener extends TestDataset {
},
errorMessage);
long reservation = reserved.get();
- AutoCloseables.close(pool);
- long finalReservation = reserved.get();
assertEquals(initReservation, reservation);
- assertEquals(initReservation, finalReservation);
+ // The failed scan can leave work running on Arrow C++ threads that still
uses the pool,
+ // and closing the scanner doesn't wait for it. Closing the pool here
would free it under
+ // that work and crash the JVM, so the pool is left open (GH-1455).
}
}