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


##########
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:
   Nit: Spark's copy of the row returned by `get()` isn't a connector call, but 
it can still overlap the task-end close (`validatedCopy` runs after the last 
`ensureOpen()`). Could this say that the row from `get()` may still be read 
while or after the cursor and reader close? A connector that frees row memory 
in `close()` should know this. `DataSourceRDD` has the same exposure; it just 
isn't documented there either.



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