spark-test commented on code in PR #60640:
URL: https://github.com/apache/spark/pull/60640#discussion_r4608572504


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ffi/NativeDataSource.scala:
##########
@@ -1428,9 +1433,11 @@ private[ffi] object NativeTask {
    * @param read whether the context is the one of a read, which the library 
may use after the
    *             task ended: an engine may read the stream of a partition 
then, and a thread that
    *             the task does not wait for may be in get_next once it 
completes, as with
-   *             `PipedRDD`. `is_interrupted` then also reports that the task 
failed or completed,
-   *             and the context does not keep the task alive. A data writer 
only runs within its
-   *             task, whose kill `is_interrupted` reports. Outside of a task, 
it reports nothing.
+   *             `PipedRDD`. `is_interrupted` then also reports that the task 
failed, or that it
+   *             started to complete, which is when the task may wait for such 
a thread, and the

Review Comment:
   **Nit (P3):** 'Such a thread' refers back to 'a thread that the task does 
not wait for ... as with `PipedRDD`' (lines 1434-1436), so this doc now says 
that the task may wait for a thread it does not wait for. The inline comment 
further down in this method (lines 1453-1455) has it right: a task that starts 
to complete stops the threads that read its input on their own, and may wait 
for one that is in get_next, such as the writer of a pipelined Python UDF. A 
maintainer who reads only this doc gets the wrong idea of which threads the 
completion-start check is for. For example:
   
   ```suggestion
      *             started to complete, which is when the task may stop and 
wait for a thread that
      *             reads its input on its own, such as the writer of a 
pipelined Python UDF, and the
   ```
   
   See **Shared repair plan 1** in the review body.



##########
sql/core/src/main/resources/org/apache/spark/sql/datasource/spark_datasource.h:
##########
@@ -542,7 +542,8 @@ typedef struct SparkDsCommitOffsetInfo {
  * may get the stream from Spark, read it in the task that opened it and 
release it later, and
  * Spark itself may read a stream on a thread that the task does not wait for, 
for example the one
  * of a PipedRDD. The task stays valid until then too, and for a read, 
is_interrupted then also
- * returns true once the task failed or completed, so the library may stop 
reading then. Such an
+ * returns true once the task failed or starts to complete, when Spark may 
wait for such a thread,
+ * and once Spark closes its reader during get_next, so the library may stop 
reading then. Such an

Review Comment:
   **Nit (P3):** In this sentence, 'such a thread' refers back to 'a thread 
that the task does not wait for, for example the one of a PipedRDD' (lines 
543-544), so the header now says that Spark may wait for a thread that it does 
not wait for. And Spark never waits for that example: PipedRDD only interrupts 
its stdin writer, from a completion listener 
(`core/src/main/scala/org/apache/spark/rdd/PipedRDD.scala:173-182`). The thread 
that a completing task stops and waits for is the writer of a pipelined Python 
UDF, through a pre-completion listener 
(`core/src/main/scala/org/apache/spark/api/python/PythonRunner.scala:221-234`), 
as the guide says (`docs/sql-native-data-sources.md:239-243`). Library authors 
build against this header to learn which threads Spark may block on while a 
task completes, so it would help to name that thread, for example:
   
   ```suggestion
    * returns true once the task failed or starts to complete, when Spark may 
stop and wait for
    * another thread that reads the stream, such as the writer of a pipelined 
Python UDF, and once
    * Spark closes its reader during get_next, so the library may stop reading 
then. Such an
   ```
   
   See **Shared repair plan 1** in the review body.



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