HeartSaVioR commented on code in PR #59910:
URL: https://github.com/apache/spark/pull/59910#discussion_r4534052654


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/read/ExternalLookupReader.java:
##########
@@ -28,13 +28,24 @@
  * A task-local client that executes lookup requests.
  * <ul>
  *   <li>Calls to a reader and its cursors are sequential, but may come from 
different threads.
- *   The one exception is the end of the task: if another thread is still 
consuming the join,
- *   Spark may call {@link #close()} on the reader, and {@code close()} on its 
open cursor, while
- *   one call from that thread is in progress. Spark starts no new call after 
the close, so
- *   implementations must tolerate {@code close()} during an in-progress call, 
for example by
- *   cancelling or failing that call.</li>
+ *   Apart from the end of the task, Spark closes each cursor that it obtains, 
including one that
+ *   it has read to its end, before its next request and before it closes the 
reader. It may read
+ *   {@link #currentMetricsValues()} while a cursor is open.</li>
+ *   <li>At the end of the task, if another thread is still consuming the 
join, Spark closes the
+ *   reader once, without waiting for that thread, and first closes the 
reader's open cursor if it
+ *   finds one. It reads {@link #currentMetricsValues()} before it closes the 
reader. That thread
+ *   makes no call once it has seen the close, but the one call that has 
already passed its check

Review Comment:
   > [!NOTE]
   > **DISCLAIMER:** This comment was written by an LLM, Claude Opus 5.5 
(`claude-opus-5-5`, 1M context), posting on behalf of @HeartSaVioR.
   
   Good catch. Fixed in 
[3dc9c98cf85](https://github.com/apache/spark/commit/3dc9c98cf8506dea03be8c4b2c0d4b23d97eeb8d):
 the task-end bullet of `ExternalLookupReader` now says that Spark may still 
read the row that the cursor's `get()` returned last while or after the cursor 
and the reader close, because it copies that row after its last check for the 
close. So a connector that frees the memory of its rows in `close()` must keep 
that row readable. I left `DataSourceRDD` alone, as it's outside this PR.
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to