Skip to content

Commit f8afc05

Browse files
committed
GH-1455: Keep TestReservationListener from closing a pool still in use
testErrorThrownFromReservationListener closed its listenable NativeMemoryPool right after the scan failed. Arrow C++ can still be running the failed scan's work on its thread pools, and that work keeps using the pool, so freeing it could crash the test JVM. Leave the pool open in that test, and close the scanner and dataset in collectResultFromFactory when the scan fails.
1 parent 9958420 commit f8afc05

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

‎dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,9 @@ protected BufferAllocator rootAllocator() {
6868

6969
protected List<ArrowRecordBatch> collectResultFromFactory(
7070
DatasetFactory factory, ScanOptions options) {
71-
final Dataset dataset = factory.finish();
72-
final Scanner scanner = dataset.newScan(options);
73-
try {
74-
final List<ArrowRecordBatch> ret = collectTaskData(scanner);
75-
AutoCloseables.close(scanner, dataset);
76-
return ret;
71+
try (Dataset dataset = factory.finish();
72+
Scanner scanner = dataset.newScan(options)) {
73+
return collectTaskData(scanner);
7774
} catch (RuntimeException e) {
7875
throw e;
7976
} catch (Exception e) {

‎dataset/src/test/java/org/apache/arrow/dataset/jni/TestReservationListener.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ public void unreserve(long size) {
122122
},
123123
errorMessage);
124124
long reservation = reserved.get();
125-
AutoCloseables.close(pool);
126-
long finalReservation = reserved.get();
127125
assertEquals(initReservation, reservation);
128-
assertEquals(initReservation, finalReservation);
126+
// The failed scan can leave work running on Arrow C++ threads that still uses the pool,
127+
// and closing the scanner doesn't wait for it. Closing the pool here would free it under
128+
// that work and crash the JVM, so the pool is left open (GH-1455).
129129
}
130130
}

0 commit comments

Comments
 (0)