DanielLeens commented on code in PR #13060:
URL: https://github.com/apache/seatunnel/pull/13060#discussion_r4598456051


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SinkWriter.java:
##########
@@ -105,6 +105,19 @@ interface Context extends Serializable {
         /** @return The index of this subtask. */
         int getIndexOfSubtask();
 
+        /**
+         * Returns the logical writer index retained across task attempts. 
Transactional sinks may
+         * use it to fence an abandoned attempt without changing the external 
identifiers of sinks
+         * that depend on {@link #getIndexOfSubtask()}.
+         *
+         * <p>On Spark this is the partition ID, while {@code 
getIndexOfSubtask()} retains the
+         * historical task-attempt ID. The stable index can be reused across 
streaming epochs; it
+         * must not be used alone as a unique identifier for a completed batch.
+         */
+        default int getStableSubtaskIndex() {
+            return getIndexOfSubtask();
+        }

Review Comment:
   Thanks for checking. `getNumberOfParallelSubtasks()` is the total writer 
count. `getStableSubtaskIndex()` identifies one logical writer across task 
attempts; on Spark it returns the partition ID, while the legacy 
`getIndexOfSubtask()` keeps its attempt-ID behavior. Kafka uses the stable 
index to build and restore the transactional writer namespace. It is not a 
unique ID for a completed streaming epoch.



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