JingsongLi commented on code in PR #87:
URL: 
https://github.com/apache/paimon-vector-index/pull/87#discussion_r3930475805


##########
python/paimon_vindex/__init__.py:
##########
@@ -512,6 +521,15 @@ def __init__(self, training: VectorIndexTraining):
             _check_error("failed to open writer")
         self._dimension = self._read_dimension()
 
+    @classmethod
+    def _from_handle(cls, handle):
+        writer = cls.__new__(cls)

Review Comment:
   [P2] Free the native handle if wrapper allocation fails
   
   At this point `create_writer()` already owns a newly allocated native 
writer, but `cls.__new__()` and `_NativeHandleLock()` can raise before 
`writer._handle` is installed. Under memory pressure, no object owns the raw 
pointer, so `__del__` cannot recover it and the cloned model is leaked. Please 
make this method an explicit ownership-transfer boundary: catch `BaseException` 
and call `paimon_vindex_writer_free(handle)` exactly once when construction 
fails. Fault-injection coverage should exercise failures both before and after 
`_handle` assignment. The existing `_read_dimension()` comment covers a later 
failure, but this earlier window is the unrecoverable one.



-- 
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]

Reply via email to