You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "yashmayya (via GitHub)" <gi...@apache.org> on 2023/07/01 10:48:07 UTC

[GitHub] [kafka] yashmayya opened a new pull request, #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

yashmayya opened a new pull request, #13948:
URL: https://github.com/apache/kafka/pull/13948

   From https://issues.apache.org/jira/browse/KAFKA-15091:
   
   > The Javadocs for SourceTask::commit state that the method should:
   > 
   > Commit the offsets, up to the offsets that have been returned by [poll()](https://kafka.apache.org/34/javadoc/org/apache/kafka/connect/source/SourceTask.html#poll()).
   > 
   > However, this is obviously incorrect given how the Connect runtime (when not configured with exactly-once support for source connectors) performs polling and offset commits on separate threads. There's also some extensive discussion on the semantics of that method in [KAFKA-5716](https://issues.apache.org/jira/browse/KAFKA-5716) where it's made clear that altering the behavior of the runtime to align with the documented semantics of that method is not a viable option.
   > 
   > We should update the Javadocs for this method to state that it does not have anything to do with the offsets returned from SourceTask:poll and is instead just a general, periodically-invoked hook to let the task know that an offset commit has taken place (but with no guarantees as to which offsets have been committed and which ones correspond to still-in-flight records).
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] yashmayya commented on a diff in pull request #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya commented on code in PR #13948:
URL: https://github.com/apache/kafka/pull/13948#discussion_r1248771658


##########
connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java:
##########
@@ -105,9 +105,11 @@ public void initialize(SourceTaskContext context) {
     public abstract List<SourceRecord> poll() throws InterruptedException;
 
     /**
-     * <p>
-     * Commit the offsets, up to the offsets that have been returned by {@link #poll()}. This
-     * method should block until the commit is complete.
+     * This method is invoked periodically when offsets are committed for this source task. Note that the offsets
+     * being committed won't necessarily correspond to the latest offsets returned by this source task via
+     * {@link #poll()}. When exactly-once support is disabled, offsets are committed periodically and asynchronously
+     * (i.e. on a separate thread from the one which calls {@link #poll()}). When exactly-once support is enabled,
+     * offsets are committed on transaction commits (also see {@link TransactionBoundary}).
      * <p>
      * SourceTasks are not required to implement this functionality; Kafka Connect will record offsets
      * automatically. This hook is provided for systems that also need to store offsets internally

Review Comment:
   I'm on the fence on whether or not to remove this bit as well since I can't think of a realistic use-case where this method would help with offset tracking in the source system in its current form (and hence the question on deprecation of this method in https://issues.apache.org/jira/browse/KAFKA-15091).



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] yashmayya commented on a diff in pull request #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya commented on code in PR #13948:
URL: https://github.com/apache/kafka/pull/13948#discussion_r1263626035


##########
connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java:
##########
@@ -105,9 +105,11 @@ public void initialize(SourceTaskContext context) {
     public abstract List<SourceRecord> poll() throws InterruptedException;
 
     /**
-     * <p>
-     * Commit the offsets, up to the offsets that have been returned by {@link #poll()}. This
-     * method should block until the commit is complete.
+     * This method is invoked periodically when offsets are committed for this source task. Note that the offsets
+     * being committed won't necessarily correspond to the latest offsets returned by this source task via
+     * {@link #poll()}. When exactly-once support is disabled, offsets are committed periodically and asynchronously
+     * (i.e. on a separate thread from the one which calls {@link #poll()}). When exactly-once support is enabled,
+     * offsets are committed on transaction commits (also see {@link TransactionBoundary}).

Review Comment:
   > I don't love how we're outlining differences in behavior when exactly-once support is enabled/disabled; it adds to the cognitive load and may tempt connector developers to write connectors that are designed to work exclusively with one mode or the other.
   
   > Could it be enough to leave this bit out and rely on the "Note that the offsets being committed won't necessarily correspond to the latest offsets returned by this source task via poll" part?
   
   Yeah, sounds good 👍 
   
   It's always a delicate balance between providing enough information to be useful and providing so much that it's overwhelming / confusing 😅 
   
   > We can also refer people to SourceTask::commitRecord for fine-grained tracking of records (though there's also no guarantee that all records that have been ack'd in that method will have their offsets committed before a call to SourceTask::commit).
   
    I've added this reference and avoided mentioning offsets commit guarantees. I guess we could explicitly mention the lack of guarantee but again it's a balancing act between providing information and introducing confusion...



##########
connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java:
##########
@@ -105,9 +105,11 @@ public void initialize(SourceTaskContext context) {
     public abstract List<SourceRecord> poll() throws InterruptedException;
 
     /**
-     * <p>
-     * Commit the offsets, up to the offsets that have been returned by {@link #poll()}. This
-     * method should block until the commit is complete.
+     * This method is invoked periodically when offsets are committed for this source task. Note that the offsets
+     * being committed won't necessarily correspond to the latest offsets returned by this source task via
+     * {@link #poll()}. When exactly-once support is disabled, offsets are committed periodically and asynchronously
+     * (i.e. on a separate thread from the one which calls {@link #poll()}). When exactly-once support is enabled,
+     * offsets are committed on transaction commits (also see {@link TransactionBoundary}).

Review Comment:
   > I don't love how we're outlining differences in behavior when exactly-once support is enabled/disabled; it adds to the cognitive load and may tempt connector developers to write connectors that are designed to work exclusively with one mode or the other.
   
   > Could it be enough to leave this bit out and rely on the "Note that the offsets being committed won't necessarily correspond to the latest offsets returned by this source task via poll" part?
   
   Yeah, sounds good 👍 
   
   It's always a delicate balance between providing enough information to be useful and providing so much that it's overwhelming / confusing 😅 
   
   > We can also refer people to SourceTask::commitRecord for fine-grained tracking of records (though there's also no guarantee that all records that have been ack'd in that method will have their offsets committed before a call to SourceTask::commit).
   
    I've added this reference and avoided mentioning offsets commit guarantees. I guess we could explicitly mention the lack of guarantee but again it's a balancing act between providing information and introducing confusion...



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] C0urante commented on a diff in pull request #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

Posted by "C0urante (via GitHub)" <gi...@apache.org>.
C0urante commented on code in PR #13948:
URL: https://github.com/apache/kafka/pull/13948#discussion_r1262996406


##########
connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java:
##########
@@ -105,9 +105,11 @@ public void initialize(SourceTaskContext context) {
     public abstract List<SourceRecord> poll() throws InterruptedException;
 
     /**
-     * <p>
-     * Commit the offsets, up to the offsets that have been returned by {@link #poll()}. This
-     * method should block until the commit is complete.
+     * This method is invoked periodically when offsets are committed for this source task. Note that the offsets
+     * being committed won't necessarily correspond to the latest offsets returned by this source task via
+     * {@link #poll()}. When exactly-once support is disabled, offsets are committed periodically and asynchronously
+     * (i.e. on a separate thread from the one which calls {@link #poll()}). When exactly-once support is enabled,
+     * offsets are committed on transaction commits (also see {@link TransactionBoundary}).

Review Comment:
   I don't love how we're outlining differences in behavior when exactly-once support is enabled/disabled; it adds to the cognitive load and may tempt connector developers to write connectors that are designed to work exclusively with one mode or the other.
   
   Could it be enough to leave this bit out and rely on the "Note that the offsets being committed won't necessarily correspond to the latest offsets returned by this source task via `poll`" part? We can also refer people to [SourceTask::commitRecord](https://kafka.apache.org/35/javadoc/org/apache/kafka/connect/source/SourceTask.html#commitRecord(org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.clients.producer.RecordMetadata)) for fine-grained tracking of records (though there's also no guarantee that all records that have been ack'd in that method will have their offsets committed before a call to `SourceTask::commit`).



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] C0urante commented on a diff in pull request #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

Posted by "C0urante (via GitHub)" <gi...@apache.org>.
C0urante commented on code in PR #13948:
URL: https://github.com/apache/kafka/pull/13948#discussion_r1267283474


##########
connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java:
##########
@@ -105,9 +105,11 @@ public void initialize(SourceTaskContext context) {
     public abstract List<SourceRecord> poll() throws InterruptedException;
 
     /**
-     * <p>
-     * Commit the offsets, up to the offsets that have been returned by {@link #poll()}. This
-     * method should block until the commit is complete.
+     * This method is invoked periodically when offsets are committed for this source task. Note that the offsets
+     * being committed won't necessarily correspond to the latest offsets returned by this source task via
+     * {@link #poll()}. When exactly-once support is disabled, offsets are committed periodically and asynchronously
+     * (i.e. on a separate thread from the one which calls {@link #poll()}). When exactly-once support is enabled,
+     * offsets are committed on transaction commits (also see {@link TransactionBoundary}).
      * <p>
      * SourceTasks are not required to implement this functionality; Kafka Connect will record offsets
      * automatically. This hook is provided for systems that also need to store offsets internally

Review Comment:
   The "store offsets internally" language isn't great, but I'd rather leave it for now and explore it further if/when we start discussing deprecating this method. Connector developers might theoretically use this for acknowledging JMS records, for example, which in a very loose sense is storing offsets (or at least, some JMS-specific equivalent of them) in that system.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] C0urante merged pull request #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

Posted by "C0urante (via GitHub)" <gi...@apache.org>.
C0urante merged PR #13948:
URL: https://github.com/apache/kafka/pull/13948


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] C0urante commented on a diff in pull request #13948: KAFKA-15091: Fix misleading Javadoc for SourceTask::commit

Posted by "C0urante (via GitHub)" <gi...@apache.org>.
C0urante commented on code in PR #13948:
URL: https://github.com/apache/kafka/pull/13948#discussion_r1267278752


##########
connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java:
##########
@@ -105,9 +105,11 @@ public void initialize(SourceTaskContext context) {
     public abstract List<SourceRecord> poll() throws InterruptedException;
 
     /**
-     * <p>
-     * Commit the offsets, up to the offsets that have been returned by {@link #poll()}. This
-     * method should block until the commit is complete.
+     * This method is invoked periodically when offsets are committed for this source task. Note that the offsets
+     * being committed won't necessarily correspond to the latest offsets returned by this source task via
+     * {@link #poll()}. When exactly-once support is disabled, offsets are committed periodically and asynchronously
+     * (i.e. on a separate thread from the one which calls {@link #poll()}). When exactly-once support is enabled,
+     * offsets are committed on transaction commits (also see {@link TransactionBoundary}).

Review Comment:
   Looks great, thanks!



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org