JingsongLi commented on code in PR #87:
URL:
https://github.com/apache/paimon-vector-index/pull/87#discussion_r4489541388
##########
java/src/main/java/org/apache/paimon/index/vector/VectorIndexWriter.java:
##########
@@ -38,6 +39,10 @@ static VectorIndexWriter fromNativePointerForTesting(long
nativePtr) {
return new VectorIndexWriter(nativePtr);
}
+ static VectorIndexWriter fromTrainingPointer(long trainingPtr) {
+ return new
VectorIndexWriter(VectorIndexNative.createWriterFromTraining(trainingPtr));
Review Comment:
[P2] Initialize the Java lock before acquiring the native writer
The native call returns an owned cloned writer before the private
`VectorIndexWriter(long)` constructor runs its field initializer
`nativeHandleLock = new Object()`. If that separate lock allocation throws
`OutOfMemoryError` in a heap-constrained build worker, construction aborts
before `nativePtr` is assigned, and the cloned native model has no owner or
cleanup path. The class has no finalizer/Cleaner, so GC and closing the
training do not reclaim it. Compiled bytecode confirms native creation precedes
constructor invocation, while lock allocation precedes pointer assignment;
neither method has an exception cleanup handler. (The wrapper's initial
allocation occurs before the native call, so that earlier allocation is not the
leaking case.) Please initialize an empty wrapper/lock first, then create and
assign its native pointer; alternatively guard the returned pointer and call
`freeWriter` if construction fails.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]